I using Twitter's Bootstrap and this color picker: http://bootstrapformhelpers.com/colorpicker/.
And I'm having an issue with these div/span/input created by library.
It uses bootstrap classes the apply display: table to div, display: table-cell to span and display: inline-block to input.
I've overwritten some CSS attributes to get my expected layout, testing it in Chrome.
However, it does not work as expected in IE9 and Firefox. Works as expected in Chrome, Opera, IE10 (and IE9#IE10).
I've reproduced it in jsFiddle, here is the important code:
HTML:
<div>
<span class="btn">
<span></span>
</span>
<input type="text" />
</div>
CSS:
body {
line-height: 20px;
}
div {
display: table;
position: relative;
width: 140px;
}
span.btn {
background: #ccc;
display: table-cell;
padding: 6px 12px;
position: relative;
left: 90px;
}
span.btn > span {
background: #333;
display: block;
height: 16px;
width: 16px;
}
input {
border: 1px solid #ccc;
display: inline-block;
height: 20px;
margin-left: -42px;
padding: 6px 12px;
width: 100%;
}
Why this is exactly happening? Every browser interpreting display: table/table-cell differently?
What is the cross-browser solution?
Because Firefox doesn't support position: relative; on table cells...
Bug Report
The issue is that you are actually having some really weird markup and CSS positioning, you should consider nesting an absolute positioned element under a relative positioned parent.
Demo
Demo 2 (With a center black box)
div {
position: relative;
width: 180px;
border: 1px solid #ddd;
margin: 20px;
height: 30px;
}
div input {
padding: 6px;
}
.btn {
position: absolute;
height: 30px;
width: 30px;
background: #aaa;
right: 0;
top: 0;
}
Related
I am making a website for my college course and I am having problems getting the button heights in my slide show to match up. I was wondering if anyone could give me a clue as to how to get them both to be at the same height?
This is my css for the slide show:
/=== SLIDESHOW SECTION ===/
#container
{
width: 90%;
height: 700px;
border: none;
margin: 0 auto;
position: relative;
}
#container > img
{
width: 100%;
height: 100%;
position: absolute;
}
#container > .btn
{
position: absolute;
width: 50px;
height: 50px;
border: none;
border-radius: 25px;
top: 350px;
background: #000000;
color: #ffffff;
font-size: 20px;
}
#container>#btn1:hover
{
box-shadow: 10px 0px 20px 0px #343d46 ;
}
#container>#btn2:hover
{
box-shadow: -10px 0px 20px 0px #343d46;
}
#container>#btn2
{
position: relative;
float: right;
}
picture of the problem
change your
#container>#btn2
{
position: relative;
float: right;
}
to
#container>#btn2
{
right:0;
}
Try adding this before #container>#btn2:
#container>#btn1
{
position: relative;
float: left;
}
Absolute positioning generally shouldn't be applied to classes (multiple elements).
I would remove the absolute positioning on your .btns and use flexbox on your container, like so:-
#container
{
width: 90%;
height: 700px;
border: none;
margin: 0 auto;
display: flex; /* adds flexbox to container */
align-items: center; /* vertically aligns everything in container */
justify-content: space-between; /* spaces the buttons as far away `enter code here`from each other as possible */
}
You can then add padding to your container for finer adjustments of your buttons horizontal distance from the container edge.
Here is my fiddle:
http://jsfiddle.net/schmudde/VeA6B/
I cannot remove the top and bottom padding on either side of a font awesome icon:
span {
border: 1px solid red;
line-height: 40%;
}
i {
border: 1px solid green;
padding: 0px;
margin: 0px;
display: inline-block;
width: auto;
height: auto;
line-height: inherit;
vertical-align: baseline;
background-color: red;
}
<span><i class="icon-check icon-3x"></i></span>
I have attempted specific line-heights and inheriting line-heights. There is something fundamental here I am clearly not understanding.
Use span { line-height: 100%; } so it would fill the block.
The line-height on the span won't help you much as the icon is added to the pseudo class :before on the <i /> tag. This pseudo class will create a somewhat hidden element, if you can call it that.
So if you want to override the css:
.icon-check:before { font-size: 2rem; }
Removing the padding of the icon can be tricky. Maybe if you set the span to display: inline-block you can use height, width in combination with overflow: hidden.
span {
border: 1px solid #FF0000;
display: inline-block;
height: 38px;
overflow: hidden;
position: relative;
width: 45px;
}
i.icon-check:before {
left: 0;
position: absolute;
top: -4px;
}
DEMO
You set borders in span, and line inheriting line-heights in i, that's the problem.
just add borders to i :
span {
line-height: 40%;
}
i {
border: 1px solid red;
border: 1px solid green;
padding: 0px;
margin: 0px;
display: inline-block;
width: auto;
height: auto;
line-height: inherit;
vertical-align: baseline;
background-color: red;
}
<span><i class="icon-check icon-3x"></i></span>
Fiddle
This weird behavior is driving me crazy.
If I upload the page on the server, the first time I open it on chrome/safari I get this problem:
If i refresh it, or when I'm working on the page locally, no problems at all.
The nav simply doesn't expand its width: auto to fit all a floated elements.
This is the really simple code (I deleted not-related rules, but if it could be useful to know I'm using a webfont):
html:
<nav>
button
button
button
<div class="clear"></div>
</nav>
css:
nav {
position: absolute;
top: 50%;
margin-top: -17px;
width: auto;
height: 33px;
}
nav > a {
box-sizing: border-box;
display: block;
float: left;
padding: 11px 13px;
height: 100%;
border: 1px solid #7a7e7f;
}
div.clear {
clear: both;
}
Basically setting the width of the nav element to 100% does the trick. Here’s an optimized example:
HTML
<nav>
button
button
button
</nav>
CSS
nav {
position: absolute;
top: 50%;
margin-top: -17px;
width: 100%;
overflow: hidden; /* Makes the clearing div obsolete */
}
nav > a {
box-sizing: border-box;
float: left;
padding: 11px 13px;
border: 1px solid #7a7e7f;
}
Check it out on Codepen: http://codepen.io/zitrusfrisch/pen/Jcirx
So I am having a problem with a label in a table cell not making room for itself and instead somehow being behind it's sibling, but taking up space INSIDE of it's sibling?
I've created a JSFiddle to show you what I mean: http://jsfiddle.net/8yzLP/
There's a label that inside a div that's inside a table cell but it's being hidden by it's sibling div.
Here's the structure markup:
<table>
<tr>
<td class="trip-finder-table-cell">
<div class="trip-finder-sort-by-container">
<label>Sort By</label>
<div class="selectList_container trip-finder-sort-by-select" tabindex="0" style="position: relative;">
<p class="selectList_value">
<span class="selectValue_content" style="cursor: pointer; display: block; text-align: left;">Sort Option</span>
<span class="select-carat" style="cursor: pointer;"></span>
</p>
</div>
</div>
</td>
</tr>
</table>
The CSS is a coming from all over, but I've included the necessary elements to recreate the problem in the JS fiddle. They are as follows:
td.trip-finder-table-cell {
width: 17%;
padding: 15px 1.25%;
vertical-align: top;
position: relative;
}
td.trip-finder-table-cell > div[class*=trip-finder] {
position: relative;
}
td.trip-finder-table-cell > div > label:not([for]) {
display: inline;
float: left;
line-height: 30px;
margin-right: 5px;
}
.selectList_value {
padding: 4px 0 4px 10px;
width: 100%;
}
.select-carat {
display: block;
width: 25px;
height: 25px;
position: absolute;
float: right;
right: 3px;
top: 2px;
background: transparent url('../img/global/forms/select-carat.png') no-repeat center center;
}
.selectList_options {
overflow: hidden;
max-height: 250px;
overflow-y: auto;
position: relative;
top: 5px;
background: #fff;
background: rgba(255,255,255,.9);
border: 1px solid #ccc;
}
.selectList_container {
min-width: 110px;
border: 1px solid #cccccc;
background: #fcfcfc;
position: relative;
}
I've tried everything I can think of to get this to work as expected (with the label to the left, and the sibling to the right), but no matter what I try it just doesn't happen. Maybe someone can be kind enough to help me out?
Your floating some elements and some are not
check ur position: xxx and float: xxx lines
mainly these lines should go
.select-carat {
position: absolute;
float: right;
right: 3px;
top: 2px;
}
td.trip-finder-table-cell > div > label:not([for]) {float: left;}
I have a div with class "opaque" and another with class "product-info", which are both on the same level.
The code is as follows:
<div class="opaque"></div>
<div class="product-info">
<img class="product-image" src="/Images/D3.jpg" />
fsdfdsfsdfs
</div>
.opaque
{
background-color: White;
-moz-opacity:.60; filter:alpha(opacity=60); opacity:.60;
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 1;
}
.product-info
{
padding: 5px;
text-align: center;
z-index: 2;
}
Note that product-info is set to z-index 2 and opaque has z-index 1. Therefore product-info should be displayed over opaque so should not be faded. However the image within product-info (and text) is faded. This happens in both Chrome and Opera, therefore I expect this is what should be happening since they are not IE!
There are lots of bits of HTML code as shown above, each nested in lis which are set to float left with width of 33%. When the page is fully loaded ($(window).load()) I use jQuery to detect the maximum height of all the products and apply that height to all the rest. I have tried removing all the jQuery in case this is affecting the z-index, but I get the same result only with an untidy look and feel.
I have tried using Google Chromes Inspect Element tool and the elements in question are showing the correct characteristics.
Can anyone see what I am doing wrong here? I have been trying to solve this for a couple of days now and would like to find out what is going on.
Thank you.
Regards,
Richard
Full code as requested:
I think this is all that is required. I will create a page with just this code in a few minutes, to see if it reproduces the problem.
<div id="BodyTag_ContentPanel">
<div class="overlay-background"></div>
<div class="scroll-pane">
<div>
<ul class="product-list">
<li class="product">
<div class="spacer">
<div class="opaque"></div>
<div class="product-info">
<img class="product-image" src="/Images/D3.jpg" />
<div class="enlarge">
<div class="image-enlargement">
<span class="close"><img src="/Images/close.jpg" /></span>
<div class="enlargement">
<div class="image-container"><img src="/Images/D3.jpg" /></div>
<div class="product-code"><span class="text-container">D3</span></div>
</div>
</div>
</div>
</div>
<div class="product-code">D3</div>
<div class="clear"></div>
</div>
</li>
</ul>
</div>
</div>
</body>
.product-list
{
list-style: none;
padding: 0;
width: 100%;
}
.product
{
width: 33%;
height: 25%;
float: left;
position: relative;
}
.product .spacer
{
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
margin: 10px;
padding: 5px;
border: 4px solid #C47F50;
position: relative;
}
.product .opaque
{
background-color: White;
-moz-opacity:.60; filter:alpha(opacity=60); opacity:.60;
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 1;
}
.product .product-info
{
padding: 5px;
text-align: center;
z-index: 2;
}
.product .product-info .product-image
{
max-width: 200px;
max-height: 200px;
min-width: 150px;
min-height: 150px;
z-index: 2;
}
.product .product-code
{
position: absolute;
bottom: -15px;
width: 50%;
margin-left: auto;
margin-right: auto;
background-color: White;
text-align: center;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
border: 4px solid #C47F50;
line-height: 20px;
z-index: 2;
}
.product .image-enlargement
{
position: fixed;
display: none;
padding: 5px;
background-color: White;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
border: 4px solid #C47F50;
z-index: 103;
}
.product .enlarge
{
float: right;
}
I have found the solution!! I simply added position: relative; to .product-info. I can't believe I was so stupid as to not try that in the first place! Thanks for both your efforts #Thomas & Lazycommit. #Lazycommit your link came in handy - it confirmed that my code should have been working if it weren't for missing out the position: relative;. I noticed that they had set the position attribute for all of the divs in the example - this is what made me try it.
This is a big theme. U may look this page from Firefox developers for better understanding browsers stacking.
Try setting the z-index of the item that is supposed to be in the back to a negative number, like -1 :)
I know this is old, but you can use rgba() instead of opacity and get rid of the "product-info" div. This does the same effect you want since rgba() uses a different method of causing transparency that does not make the children elements go transparent as well. Makes doing the effect you wanted much easier.
if there is outer div to set position: fixed; and you need position: fixed; there add z-index same as inner div.
ex:
.notifications {
position: fixed;
width: auto;
max-width: 70%;
z-index: 9999;
}
.notifications > div {
position: relative;
z-index: 9999;
/* margin: 5px 0px;*/ /*default value*/
margin: 65px 10px;
display: inline-block;
}
will work fine.
But if notifications class like below it does not set z-index in chrome correctly.
.notifications {
width: auto;
max-width: 70%;
z-index: 9999;
}