Nested DIV with inline-block in Safari causes sibling elements of parent to be misaligned - safari

I am trying to align a set of "buttons" made out of DIV elements that are arranged along the bottom of a web page using the CSS display: inline-block. I've attached a fiddle which illustrates the issue.
The problem is that this current code works on all modern browsers except Safari (7, 8). I don't know if this is a bug in WebKit that Safari uses, or something that I've allowed to happen by not using the right incantations.
The thing that triggers the unwanted behavior is the nested DIV.btn-sub; however, removing that text is not an option to "fix" the issue.
Here's the expected behavior (snap taken from Firefox 34, similar behavior on IE 9, 10, and latest Chrome):
Here's what happens on Safari:
Any help here would be appreciated!

It's usually best practice to use a list when creating inline-blocked elements in a row/list, such as a navigation.
The issue here seems to be the block being set with a padding directly; relative it's parent. Which somehow is turning it into a margin or something similar.
You can try stripping CSS until you get a full height out of the blocks, and then add another inner div which you can call .btn-padding which contains your top padding.
Here is similar.
body, html {
height: 100%;
margin: 0;
background: green;
}
#wrap {
display: block;
width: 100%;
position: fixed;
bottom: 0px;
height: 50px;
border:0;
background-color: blue;
color: #fff;
}
#btnls {
display: block;
list-style-type: none;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#btnls li {
display: inline-block;
margin-right: 10px;
background-color: purple;
min-width: 158px;
max-width: 300px;
height: 50px;
text-align: center;
vertical-align: middle;
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
#btnls li .btn-padding {
display: block;
padding-top: 10px;
width: 100%;
height: 50px;
}
#btnls li .btn-padding .sub-btn {
display: block;
font-size: x-small;
margin: 0;
padding: 0
}
<div id="wrap">
<ul id="btnls">
<li>
<div class="btn-padding">Foo
<div class="sub-btn">Bar</div>
</div>
</li>
<li>
<div class="btn-padding">Foo</div>
</li>
<li>
<div class="btn-padding">Foo</div>
</li>
</ul>
</div>

Related

tooltip with arrow with vue's style binding

I want to create tooltip with vue's style binding. I am thinking to use attr() function from CSS which takes attribute value which is a reactive object dynamicColor. The code which I have now is:
<div class="test">
<span class="marker" :style="{'background': dynamicColor}" :color="dynamicColor">
smallText
</span>
</div>
<style>
div.test span.marker {
position: absolute;
width: 28px;
height: 15px;
border-radius: 2px;
display: block;
top: -25px;
font-size: 10px;
text-align: center;
}
div.test span.marker::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 6px;
border-style: solid;
border-color: attr(color) transparent transparent transparent;
}
</style>
But it does not work. I don't want to use bootstrap due to some reasons. I tried to look if I can find for pseudo selector in vue style binding but could not find much. Any ideas on how to achieve this? Thanks.
As suggested by #Stephan-v in comments, I added separate element for arrow. The final code looks like something below:
<div class="test">
<span class="markertip" :style="{'border-color': dynamicColor + ' transparent transparent transparent'}"></span>
<span class="marker" :style="{'background': dynamicColor}">
smallText
</span>
</div>
<style>
div.test span.marker {
position: absolute;
width: 28px;
height: 15px;
border-radius: 2px;
display: block;
top: -25px;
font-size: 10px;
text-align: center;
}
div.test span.markertip {
content: "";
position: absolute;
top: -45%;
margin-left: -5px;
border-width: 6px;
border-style: solid;
}
</style>

Center align absolute elements inside flex items

I'm trying to horizontally align two absolute positioned elements inside a flex item.
This is my current CodePen
HTML :
<div class="stepper-wrapper">
<ul class="step-wrapper" >
<li class="step__bubble"></li>
<li class="step__circle"></li>
</ul>
<ul class="step-wrapper" >
<li class="step__bubble"></li>
<li class="step__circle"></li>
</ul>
</div>
CSS :
.stepper-wrapper {
display: flex;
flex-direction: row;
}
ul {
border: 1px solid grey;
height: 0px;
position: relative;
top: 40%;
min-width: 100px;
flex: 1;
li.step__bubble {
display: inline-block;
vertical-align: middle;
}
li.step__bubble::before {
content: "";
position: absolute;
top: -9px;
left: calc(50%);
display: block;
width: 16px;
height: 16px;
border: 2px solid grey;
border-radius: 50%;
background: white;
}
li.step__circle {
width: 8px;
height: 8px;
border: 1px solid red;
border-radius: 50%;
display: block;
position: absolute;
top: -4px;
left: calc(50% + 1px);
}
}
What I want to do is :
Having the grey circle vertically and horizontally aligned over the
line. Vertically is not really a pb, I'm able to set a fixed value as the height of the .stepper-wrapper will be fixed. Horizontally needs to be adaptative and it's where I'm stuck.
Having the red circle right inside the grey circle
I tried to use the calc() function and set it to (50% - width_of_element_in_px/2) for both circles, but I don't know why, each px seems to be ~10px.
Thx for your help
Welcome to the club of the LESS users pwned by calc() and string interpolation
I've been using LESS since 5 years and it still happens from time to time :(
Sooo tl;dr calc() was and is a LESS function that its compiler will happily output as some result (probably 50% + 10(stripped) => 60%).
If you want LESS compiler to output calc() the CSS Level 3 function, you need to escape it, that is wrap it in ~"calc(50% + 5px)"!
Codepen
EDIT: also see https://stackoverflow.com/a/17904128/137626
EDIT2: couldn't find an entry about calc in LESS documentation oO but the problem is explained in http://lesscss.org/usage/#command-line-usage-options (search "calc" in text). strict-math is a cool option but you'll have to make sure everybody else has it activated (won't be the case by default)

Is this possible? transparent png over slide revolution (clickable)

I want two slide revolutions (or at least one), but with this skin over it:
The overlay image would be on top of the images, so clicking the gallery would be impossible (and the bullets to change image inside of it). I know about map coordinates, but it's a slider revolution, so it will not work in this case I think.
Is there any way to achieve this?
My HTML & CSS so far: (JSFiddle)
<div class="thePNG"></div>
<div class="theSLIDERS">
<div class="fakeSLIDER1">HEY' IM CLICKABLE</div>
<div class="fakeSLIDER2"></div>
</div>
.thePNG {
background-image: url(my-overlay-image.png);
width: 787px;
height: 610px;
background-size: cover;
z-index: 2;
position: relative;
}
.theSLIDERS{
margin-top: -600px;
z-index: 1;
}
.fakeSLIDER1{
background-color: red;
width: 700px;
height: 300px;
text-align: center;
margin: 0 auto 0 auto;
}
.fakeSLIDER2{
background-color: green;
width: 700px;
height: 300px;
}
I found my own answer!
its easy:
CSS:
"pointer-events: none;"
!

Header and Background Image Fixed Content and Footer scrolling

I have setup a fiddle for my issue Fiddle. What my requirement is? I need the header and the background image to be fixed only. The content should be scrolling, and the footer should also scroll with the content.
CSS
body{
margin: 0;
}
header{
height: 50px;
background: black;
width: 100%;
}
section{
background: url(http://dummyimage.com/600x400);
height: 400px;
repeast: no-repeat;
}
footer{
height: 50px;
background: black;
position: fixed;
width: 100%;
}
.clearfix{
width: 960px;
height: 400px;
margin-left: auto;
margin-right: auto;
border: 5px solid #fff;
}
HTML
<header></header>
<section>
<div class="clearfix">
What my requirement is? I want the footer and background image to be position fixed and the footer should be scrolling with the large content.
</div>
</section>
<footer></footer>
Thanks guys.
Use overflow:scroll; to scroll your content
.clearfix{
width: 960px;
height: 400px;
margin-left: auto;
margin-right: auto;
border: 5px solid #fff;
overflow:scroll;
}
You can write your footer inside your div, this will scroll the footer with content

Why does a background break a box-shadow inset effect?

Im trying to achieve an inner-shadow effect on a simple box, something like:
alt text http://gotinsane.com/test.jpg
where the green box is the content inside another box.
My problem is that if i give the content box any kind of background, the outer box box-shadow effect vanish!
Here an example of my problem (with markup and css), i've set the content height smaller to evidence the problem - atm i really dont care about IE*, this is just a test.
Any idea?
UPDATE
The content inside the box is a somewhat kind of slide, here an example (original problem).
thirtydot's answer does the trick, but it forces me to make a little hack, changing the wrapper background in function of the content: example here (thirtydot trick).
This can be a solution, but i dont like it too much and still dont understand why the outer box shadow get behind the inner box background (color, image)
UPDATE 2
Talking about this problem on another forum, i found another way: basically, instead of use box-shadow on the wrapper, that will act as a mask, I use box-shadow and border-radius directly on the content (.step elements)
However, the 'mask' effect is exactly what i was trying to accomplish, so this isnt the solution neither.
I still don't understand how and why an inner element background interfere with an outer element design, or why the shadow dropped from the outer element get behind the inner one. Could this be a css bug?
UPDATE3
Someone opened a bug on mozilla, and got this answer that clearify the 'problem':
From http://www.w3.org/TR/css3-background/#the-box-shadow :
In terms of stacking contexts and the painting order, the outer shadows of an
element are drawn immediately below the background of that element, and the
inner shadows of an element are drawn immediately above the background of
that element (below the borders and border image, if any).
In particular, the backgrounds of children of the element would paint above
the inset shadow (and in fact they paint above the borders and background of
the element itself).
So the rendering is exactly what the spec calls for.
UPDATE4
Fabio A. pointed out another solution, with css3 pointer-events.
Looks good and works on IE8 too ;)
Since I am having this problem too and I too don't see this behaviour being normal, I filed a bug report over at mozilla
I can reproduce the problem in Google Chrome too, though, so I wonder whether this is really a bug. But it could be.
edit:
Indeed it's not a bug, but just the way it's meant to work. So, on the basis of this information, I forked your jfiddle example and came up with this solution:
The markup now looks like this:
<div id="box">
<div id="wrapper">
<div id="box_content">
Content here
</div>
<div id="mask"></div>
</div>
</div>
The mask becomes another div, which is layered on top of the #box_content one by means of being absolutely positioned. This is the CSS:
#wrapper{
position: relative;
display: inline-block;
width: 280px;
height: 280px;
border-radius: 5px;
margin: 10px;
}
#mask {
position: absolute;
top: 0px; left: 0px;
width: 100%;
height: 100%;
pointer-events: none; /* to make clicks pass through */
box-shadow: 0 0 10px #000000 inset;
}
#box_content{
background-color: #0ef83f;
height: 100%;
}
I'm a little confused what you're actually after. If it's not quite right, let me know :)
This is my best guess.
Live Demo
CSS:
(I added in the vendor prefix rules.)
#box {
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 0 10px #000;
-moz-box-shadow: 0 0 10px #000;
box-shadow: 0 0 10px #000;
width: 280px;
height: 280px;
padding: 10px
}
#wrapper {
background-color: #0ef83f;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: inset 0px 0px 18px #000;
-moz-box-shadow: inset 0px 0px 18px #000;
box-shadow: inset 0px 0px 18px #000;
width: 240px;
height: 240px;
padding: 20px
}
HTML:
<div id="box">
<div id="wrapper">
Content here
</div>
</div>
the problem is layered is overlapped, you can avoid it using margin or padding.
Try
http://jsfiddle.net/pramendra/FEk3c/5/
#box{
background-color: #FFFFFF;
border-radius: 10px 10px 10px 10px;
box-shadow: 0 0 10px #000000;
width: 300px;
height: 300px;
}
#body{
margin: 0px;
}
#wrapper{
display:inline-block;
width: 280px;
height: 280px;
border-radius: 5px;
box-shadow: 0 0 10px #000000 inset;
box-shadow:inset 0 0 10px 0 #000000;
margin: 10px;
}
#box_content{
background-color: #f00;
margin:5px;
}
Check this fiddle: http://jsfiddle.net/FEk3c/6/
#box{
background-color: #FFFFFF;
border-radius: 10px 10px 10px 10px;
box-shadow: 0 0 10px #000000;
width: 300px;
height: 300px;
}
#body{
margin: 0;
}
#wrapper{
display: inline-block;
width: 280px;
height: 280px;
border-radius: 5px;
box-shadow: 0 0 10px #000000 inset;
margin: 10px;
}
#box_content{
background-color: #0ef83f;
height: 100px;
}
Just make sure the child background property is specified with rgba, like in this fiddle.
Give the parent a background-color to prevent whatever's underneath showing through.
ul {
box-shadow : inset 0 0 10px 10px gray;
background-color: white;
}
li:nth-child(even) {
background : rgba(255,0,0,0.2);
}
This works great for me without any additional DOM elements (like 'wrapper' etc.):
div.img {
display: inline-block;
position: relative;
width: 400px;
height: 280px;
background-image: url(/images/anyimage.png);
}
div.img:after {
display: inline-block;
width: 100%;
height: 300px; //parent height +20px
position: absolute;
top: -10px;
left: 0;
box-shadow(inset -25px 0 25px -25px rgba(0,0,0,.2), inset 25px 0 25px -25px rgba(0,0,0,.2));
content: ' ';
pointer-events: none;
}