So I try to make my styles dependent from conditions but it mess with almost everthing.
So here is the current state:
<style>
#bodyContainer {
width: 1024px;
margin: 0 auto 0 auto;
background: lightgreen;
}
#navbar {
width: 1024px;
margin: 0 auto 0 auto;
}
#layoutContent {
width: #if (!IsSectionDefined("menu"))
{
#:1024
}
else
{
#:724
}
px;
padding-top: 70px;
background: lightblue;
}
#if (IsSectionDefined("menu"))
{
#:#menu {
#: padding-top: 70px;
#: float:left;
#: background:lightgray;
#: width: 300px;
#:}
}
</style>
It's working (the code, not the layout itself:) ) but:
- the highlight not working in menu section
- the intellisense/highlight not working in the rest of the style tag
- the style inside the if statement looks like a mess
- the generated text looks like a mess:
#layoutContent {
width: 724
px;
padding-top: 70px;
background: lightblue;
}
#menu {
padding-top: 70px;
float:left;
background:lightgray;
width: 300px;
}
I really appritiate any idea.
CSS doesn't work like that, and you shouldn't attempt to mix Razor with CSS.
You should have 2 styles and then based upon the condition apply the class to the HTML elements.
For example, have a separate file for CSS:
#menu724 {
padding-top: 70px;
float:left;
background:lightgray;
width: 724px;
}
#menu1024 {
padding-top: 70px;
float:left;
background:lightgray;
width: 724px;
}
Then in your view you could do:
#if (MenuSectionDefined) {
<div id="menu1024">
Content
</div>
} else {
// display the appropriate elements without the `menu` CSS style
<div id="menu724">
Content
</div>
}
Ok. I make a final solution use the advices I got.
Body part:
<div id="bodyContainer">
<div id="navbar" class="navbar navbar-default navbar-fixed-top">
</div>
#if (IsSectionDefined("menu"))
{
<div class="menu">
#RenderSection("menu")
</div>
}
<div class="container layoutContent #(IsSectionDefined("menu") ? "layoutContent724" : "layoutContent724")">
#RenderBody()
</div>
</div>
Style part:
.layoutContent {
padding-top: 70px;
background: lightblue;
}
.layoutContent724
{
width: 724px;
}
.layoutContent1024
{
width: 1024px;
}
.menu {
padding-top: 70px;
float: left;
background: lightgray;
width: 300px;
}
I let the question in place in case somebody run in the same situtation.
The final answer to the question I think is "No way!". This approach is totally wrong.
Related
For some reason once you expand the window the chart doesn't resize down properly. You should still be able to see the red spacer.
I made an example here: https://jsfiddle.net/bryaan/pjyzxbdu/10/
<div class="table-row">
<div class="table-cell">
<div id="container"></div>
</div>
<div class="table-cell">
<div class="spacer"></div>
</div>
</div>
.table-row {
display: flex;
margin 10px;
}
.table-cell {
width: 100%;
height: 100%;
min-height: 100px;
}
.spacer {
width: 100%;
height: 100px;
background-color: red;
}
If you want to achieve two equal boxes sets display:flex to parent and add children width: 50%.
.flex {
display: flex;
}
#container {
width: 50%;
}
.spacer {
width: 50%;
height: 500px;
background-color: red;
}
Demo: https://jsfiddle.net/BlackLabel/46o7venk/
Is there an event that I can listen to, when Flickity has finished initialization?
When initializing with JavaScript, I can trigger an event by myself, but by using this setup I have no clue.
Initialize with HTML
http://flickity.metafizzy.co/#initialize-with-html
<div data-flickity='{ … }'>
…
</div>
Currently, I am checking if Flickity has generated it's DOM elements, but that is not very elegant. :-)
You can try this:
Flickity.prototype.on( 'activate',function(){
alert("active")});
Flickity.prototype.on( 'activate',function(){
alert("active")});
/* external css: flickity.css */
* { box-sizing: border-box; }
body { font-family: sans-serif; }
.carousel {
background: #EEE;
}
.carousel-cell {
width: 100%;
height: 200px;
margin-right: 10px;
background: #8C8;
border-radius: 5px;
counter-increment: gallery-cell;
}
/* cell number */
.carousel-cell:before {
display: block;
text-align: center;
content: counter(gallery-cell);
line-height: 200px;
font-size: 80px;
color: white;
}
<script src="https://npmcdn.com/flickity#2/dist/flickity.pkgd.js"></script>
<!-- Flickity HTML init -->
<div class="carousel" id="carousel" data-flickity>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
</div>
I made a simple flippable element using common techniques and found some strange behavior in Mobile Safari on iOS 7 (older version also may be affected, unfortunately I can't test them at the moment older versions also seem to be affected), please see the images below or visit a demo directly on your iOS device.
Editable markup and stylesheet
Full screen view to visit on your iOS device
<div class="flippable">
<input id="flippable-trigger" type="checkbox">
<label for="flippable-trigger" class="flippable-faces">
<div class="flippable-face-front">
Front
</div>
<div class="flippable-face-back">
Back
</div>
</label>
</div>
body {
font: 1em/0 Arial;
background-color: silver;
}
.flippable {
position: relative;
float: left;
width: 10rem;
height: 10rem;
-webkit-perspective: 800;
}
.flippable input[type="checkbox"] {
display: none;
}
.flippable-faces,
.flippable-face-front,
.flippable-face-back {
position: absolute;
width: 100%;
height: 100%;
}
.flippable-faces {
-webkit-transform-style: preserve-3d;
-webkit-transition: 600ms;
}
.flippable-face-front,
.flippable-face-back {
position: absolute;
width: 100%;
height: 100%;
line-height: 10rem;
text-align: center;
-webkit-box-shadow: 0 0 1rem gray;
-webkit-backface-visibility: hidden;
}
.flippable-face-front {
color: black;
background-color: white;
}
.flippable-face-back {
color: white;
background-color: black;
-webkit-transform: rotateY(180deg);
}
.flippable input[type="checkbox"]:checked ~ .flippable-faces {
-webkit-transform: rotateY(180deg);
}
It appears that repositioning your divs fixes the issue. I don't have an answer as to why that was happening though. Sorry. Working Example | Example for iPhone
<div class="flippable">
<input id="flippable-trigger" type="checkbox" >
<label for="flippable-trigger" class="flippable-faces">
<div class="flippable-face-back">
Back
</div>
<div class="flippable-face-front">
Front
</div>
</label>
</input>
</div>
Page A has an iframe (that loads Page B). That Page B has a div#OutputDiv. My goal is to make that div in that iframe scrollable.
SOLUTION (CREDIT TO STEVE!):
Include overflow: auto for that div. However you must specify height too. Simply give any fixed value. eg height: 0.
Use a javascript function to make the div's height always same as the window's, even after window resize. height is now not fixed.
Code:
#outputDiv {
font-size: 12px;
font-family: Arial;
margin-right: 1em;
overflow: auto;
overflow-x: hidden; (optional)
-webkit-overflow-scrolling: touch; (enable smooth scrolling on mobile)
height: 0; (omit-able)
}
$(window).resize(function(){
$("#outputDiv").css("height",0).css("height",$(this).height());
});
$(window).trigger("resize");
TL;DR Full story
Page A.html - has an iframe to load Page B. When on Page A, that div#OutputDiv in that iframe must be scrollable. Works fine on PC but not scrollable on iPad/Android. Page structure:
Page B.php - Left half div#OutputDiv, right half div#map-canvas containing Google Maps.
(Sidenote: I think the #map-canvas CSS is pretty unchangeable, for example changing something may cause the Maps to extend height beyond browser height, which is not what I want.)
Page A.html
<style type="text/css">
#title-banner {
position: fixed;
top: 0;
left: 0;
width: 100%;
}
#real-time-alert {
margin-top: 155px;
margin-left: 10px;
}
.tab-content {
border-left: 1px solid #ddd;
padding: 10px;
height: 100%;
}
#map {
height: 100%;
}
.nav-tabs {
margin-bottom: 0;
}
#panel {
position: fixed;
top: 120px;
right: 10px;
bottom: 10px;
left: 350px;
}
iframe {
width: 100%;
height: 100%;
}
</style>
<body>
<div id="title-banner" class="well"><h1>Real-time incident updates</h1></div>
<div id="real-time-alert">
DEMO:<br>
<a id="demolink" style="cursor: pointer; font-weight: bold;">22/11/2013, 0.32.18AM: 3.128268, 101.650656<br></a>
</div>
<div id="panel">
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a data-toggle="tab" href="#map">Map</a></li>
<li><a data-toggle="tab" href="#message">Messages</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="map"><iframe seamless name="map-report"></iframe></div>
<div class="tab-pane" id="message"></div>
</div>
</div>
</body>
Page B.php
*for div#map-canvas, I had to do the code below, or else when I hover on the page, div#OutputDiv will disappear. This may be not important.
$("*").hover(function(){
$("#map-canvas").css("position","fixed"); });
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map-canvas {
height: 100%;
width: 50%;
}
#content-pane {
float:left;
width:48%;
padding-left: 2%;
}
#outputDiv {
font-size: 12px;
font-family: Arial;
margin-right: 1em;
}
</style>
<body>
<div id="content-pane">
<div class='well well-small' id="inputs" style="margin: 1em 1em 0 0">
<b>TESTING ONLY</b> <br>
<label for="originLat">Incident Site: </label><input type="text" id="originLat" style="width:6em;" />
<input type="text" id="originLng" style="width:6em;" />
<button type="button">Calculate distances</button>
</br>eg. 3.126547,101.657825
</div>
<div id="outputDiv"></div>
</div>
<div id="map-canvas" style="position: fixed; right: 1px;"></div>
</body>
I can't see any overflow controls specified in the CSS (apologies if I missed them).
Have you tried:
div#OutputDiv { overflow: auto; height: 200px; }
The height is just for testing purposes - but you could use Javascript to get the actual height and apply it using either raw javascript or jQuery.
A good example (including how to detect orientation changes if device goes portrait to landscape or similar) can be found on:
How do I get the new dimensions of an element *after* it resizes due to a screen orientation change?
I'm having some difficulty getting my website to display properly when viewed on the iPhone and iPad. The website displays properly when viewed on every desktop browser I've tried (safari, chrome, firefox), however, on the iPhone/iPad there is a tiny gap/space between the IMG and right box.
It works fine in Firefox. What is the problem?
Here's an inline link to JsFiddle.
<div id="wrapper">
<img src="http://dummyimage.com/155x155/000/fff"/>
<div id="subject">
<div id="subject_wrapper">
<span>Im span</span>
<span>im spanfdnf</span>
</div>
</div>
</div>
#wrapper {
border-top: 8px solid #457b91;
max-width: 488px;
margin: 0 auto;
overflow: hidden;
}
#wrapper img {
width: 32%;
float: left;
}
#subject {
background-color: green;
float: right;
width: 68%;
padding-bottom: 32%;
position: relative;
}
#subject_wrapper {
padding-top: 12%;
position: absolute;
height: 100%;
width: 100%;
}
#subject span {
font-family: Thonburi;
font-size: 34px;
color: #ffffff;
display: block;
padding: 0 20%;
}
#subject span:nth-child(2) {
font-size: 18px;
line-height: 8px;
}
I don't have an iPd or iPhone to hand to check this, but try commenting out the space between your elements, thus:
<div id="wrapper">
<img src="http://dummyimage.com/155x155/000/fff"/><!--
--><div id="subject">
<div id="subject_wrapper">
<span>Im span</span>
<span>im spanfdnf</span>
</div>
</div>
</div>
It's a pretty ridiculous fix, but it work for inline block elements, like menus made up of LIs.