I'm trying to design a fullscreen-menu. It works very good but when the page itself contains a bootstrap grid-system, the grid always is in the front. Using Google Chromes developer tools i found, it's due to all col-*s contain
position: relative
If I disable it in developer tools (then position is static), it's in background.
But imho I can't just edit the whole bootstrap-css.
This is my html (removed what's too much):
<div class="header">
<input type="checkbox" id="toggle" style="display:none;" />
<label class="toggle-btn toggle-btn__cross" for="toggle">
<div class="bar"></div>
</label>
<label class="info">
test
</label>
<div class="nav">
<div class="menu">
<!-- here is the menu -->
</div>
</div>
</div>
<div class="container body-content">
<div class="wrap">
<div class="row">
<!-- THIS HERE IS ALWAYS IN FRONT DUE TO POSITION:RELATIVE -->
<div class="col-xs-6">key</div>
<div class="col-xs-6">value</div>
</div>
</div>
<hr/>
<footer>
<p>footer</p>
</footer>
</div>
the header-class is the whole navigation that displays or hide the div with class menu. The div hides the complete content of class body-content (at least it should).
So
is there a cause why all col-classes are set to relative? I don't want to get any bad surprises later.
what are the possibilities (or the correct solution) to get the grid-system in background?
position: relative is necessary in Bootstrap for when you need to rearrange columns. This is accomplished by using col-sm-push-4 or similar classes. I do not recommend overriding it as that could make your project a maintenance nightmare in the future. It's better to use the property that was designed to override painting order: z-index. Try to be careful when using this property because it tends to get abused quite a bit.
First, you only really need two rules for your case
.header {
position: relative;
z-index: 1
}
position: relative is needed because z-index does not affect position: static elements (the default). z-index only needs to be 1. If you find yourself needing to set it to absurdly high levels (like the 1000s) you likely just need to set the z-index of .body-content, in which case, just set it to 1 on .body-content and 2 on .header.
Either way, that should be all you need.
Related
I'm building a feature that has three circles inside of container that are next each other. Initially when I began building this feature I thought that I could just drop my circles into a flex container and they would all be good when I added media quires and resized the page.
Much to my despise that was not the case..The circles went inside of the container perfectly but when I started to resize page I noticed that they were squishing! I know this because border-radius:50% as circles need to be a percentage and when they are pressed they change there size bc they are fluid.
This issue prompted me to think of solution to prevent the circles from squishing. I had an idea of surrounding divs around the circles which would possibly stop them squishing so looked around to see if anyone had done this before.
Much to my liking I found a solution that someone had posted on STO. I modified the solution slightly to meet my own needs which works fine but there's a small issue here, I'm not sure I like the way it makes my markup look. Messy messy messy!
Solution
<!-- Projects -->
<div class="circles">
<div>
<div>
<div>
<div class="projects">
Projects
</div>
</div>
</div>
</div>
<!-- About -->
<div>
<div>
<div>
<div class="about">
About
</div>
</div>
</div>
</div>
<!-- Contact -->
<div>
<div>
<div>
<div class="contact">
Contact
</div>
</div>
</div>
</div>
Compared to my original markup there is a clear difference in the less amount of divs
Original
<div class="gridRow">
<div class="gridItem1">
Projects
</div>
<div class="gridItem2">
About
</div>
<div class="gridItem3">
Contact
</div>
</div>
I'm want to figure a way to clean up the solution markup a little more but I'm not really sure if there's a way to do that..I don't want to use svg as I just want a css solution. Any ideas?
Fiddles here
Squishing circles
https://jsfiddle.net/kapena/vmt54cd0/
Responsive Circles
https://jsfiddle.net/kapena/vmt54cd0/
Try adding these to the gridItem styles:
min-width:200px;
width:200px;
max-width:200px;
min-height:200px;
height:200px;
max-height:200px;
My buttons don't work when I put .pull-left. I tried using the W3C validator on the document, but no problem detected.
Here's the code.
Because you've made .secondline display as block and are positioning it, it's "covering up" the button.
You can keep it block level, but instead of positioning along an axis, try positioning with line-height.
.secondline {
width: 100%;
z-index: 1;
display: block;
line-height: 24px;
}
However, I think it's a better end result to use the grid system for this. Below is an example of what you could do using the content from your first result. (Of course, you would need to add your code and content)
<div class="row">
<div class="col-xs-12">
V ➜ GARE CORNAVIN (21:44)
</div>
</div>
<div class="row">
<div class="col-xs-6">
Button
</div>
<div class="col-xs-6 text-right">
19 minutes
</div>
</div>
You're dealing with HTML structure issue rather than a Bootstrap issue. One of your HTML elements appears to be covering the button. It appears as though it's your "time" span. I would recommend trying to restructure your HTML with your button in a div class and the minutes in another div class. You have a lot of span elements there that could probably be eliminated to simplify your markup.
Another solution is to increase the z-index of the covered element, your code is no longer linked but try adding style="z-index:2147483647" to the parent of the element with .pull-left
Hi, sometimes learning something makes you more confused, I am in that position right now, thanks in advance.
I asked a question in this address: Why <div class="clear"></div> used?
After getting the answer and accepting (I also read the links given in comments section), now I've 2nd and 3rd questions.
According to the input codes given in related question,
Why grid demo code below didn't use <div class="clear"></div>? Again there exist 2 sets of two floating div elements so isn't it suitable to use <div class="clear"></div> just after the last floating div elements?
I explicitly mention that I would expect <div class="clear"></div> code in 2 places: Just after <div class="col col_7"> and just after <div class="col col_4">
<div class="row">
<div class="col col_1">col_1</div>
<div class="col col_7">col_7
<div class="row">
<div class="col col_3">col_3</div>
<div class="col col_4">col_4</div>
</div><!-- row -->
</div>
</div><!-- row -->
</div><!-- col_8 -->
The owner of accepted answer wrote that: "Without this the content following your nav element may appear alongside your nav element rather than below it." Since he used MAY grammar & I deleted <div class="clear"></div> and saw that nothing has changed in output for IE9 and Chrome 25.0.1364.172; what maked him to write MAY? Old browsers (especially old IE versions)?
This depends on your CSS that is associated with the different classes/ids/elements in your HTML.
<div class="clear"></div> ALWAYS has some css associated with it, that is:
.clear { clear: both; }
The above CSS is what makes it prevent that floating issue. That said... Using a "clear div" as you have shown above is one of many ways to do this.
In your particular case, given this HTML:
<div class="row">
<div class="col col_1">col_1</div>
<div class="col col_7">col_7
<div class="row">
<div class="col col_3">col_3</div>
<div class="col col_4">col_4</div>
</div><!-- row -->
</div>
</div><!-- row -->
</div><!-- col_8 -->
It is very likely that the class of "row" has the clear: both; property in CSS. That would explain why when you remove the clear div, it stayed the same. Essentially you didn't need the clear div, because the row class already has the CSS attached to it to prevent that issue from happening.
The selector probably looks like this: .row { clear: both; } The .row class probably has other CSS associated with it as well, another very likely property is overflow: hidden; That property can also effect how your divs and surrounding divs interact/behave next to each other.
To summarize: It is NOT the HTML <div class="clear"></div> that prevents this floating issue from happening. It IS the CSS property and value clear: both; which can be applied to any HTML element that prevents the issue from occurring.
Some resources:
CSS Wiki on Overflow property
CSS Wiki on Clear property
Hopefully this clears that up for you? (pardon the pun haha)
How can I make the labels of the form fields align vertically with the billing address heading?
http://jsfiddle.net/DA9gK/1/
<h4 class="billingAddress">Billing Address</h4>
<div class="control-group">
<label class="control-label" for="inputEmail">Company Name</label>
<div class="controls">
<input type="text" id="inputEmail">
</div>
</div>
Add
.form-horizontal .control-label {
text-align: left;
}
to your CSS part...Is this what you want?
Take a look at the css box model and if you can implement that, your spacing issues should go away. Floats are some else to consider, but... what you would benefit from specifically here... I can't find the link to, so do this:
<div id="head"></div>
<div id="nav"></div>
<div id="wrapper"></div>
<div id="leftcolumn"></div>
<div id="rightcolumn"></div>
<div id="footer"></div>
you can share a line between head & nav based on your style, your left form objects go into leftcolumn, right into right, footer holds its own line typically. This relies on absolute positioning of the wrapper and relative positioning of the everything else I believe. Floats work too, but are considered less flexible.
This approach should give you the kind of control over the spacing you need to make your page "fiddler" example look good.
I have a layout built using CSS display:table (inline, row, cell, etc). I'm doing local development on it with apache, and when I refresh the page, two of the div containers are incorrectly lined up. However, if I uncheck and re-check display:table-row, they correct themselves, and the page displays correctly.
http://jsfiddle.net/fNNKT/
You can see the HTML and CSS at the jsFiddle above. It's actually not working there either, so maybe I'm doing something wrong, and can use help with that.
<div class="cabinet-container">
<div class="mode-bar">
<div class="mode-bar-left">
<div class="mode-bar-item">logo</div>
<div class="mode-bar-item active">Dispense</div>
<div class="mode-bar-item">Inventory</div>
</div>
<div class="mode-bar-right schedule">
<div class="mode-bar-item">Sign-Out</div>
</div>
</div>
<div class="table"></div>
<div class="left-container"></div>
<div class="center-container">
<div class="search-container">
<div class="table-cell">
<div class="search-field"></div>
</div>
</div>
<div class="nav-button-center-container">
<div class="table-cell">
</div>
</div>
<div class="list">
<div class="table-cell">
<div class="list-item-center-container"></div>
<div class="list-item-center-container"></div>
<div class="list-item-center-container-partial"></div>
</div>
</div>
<div class="nav-button-center-container-down-active">
<div class="table-cell"></div>
</div>
</div>
<div class="footer">
<div class="button-group table-border-5">
<div class="button-secondary">Dispense Non-Drug</div>
<div class="button-secondary">Sort By: Last Name</div>
</div>
<div class="button-group-right table-border-5">
<div class="button-primary">New Clinical Order</div>
</div>
</div>
</div>
Is your question related to .mode-bar-left and .mode-bar-right wrapping onto two lines? If so, the problem relates to whitespace. Think of two images displayed inline, side by side. If there's whitespace between the tags in the code, there will be whitespace displayed in the browser.
Solution #1:
Take your logic one level higher up in the DOM. Change the display value for both mode-bar elements to table-cell (instead of the current inline-table). Then change the .mode-bar-item elements to display: inline-block (instead of table-cell).
Solution #2:
A faster, less elegant solution is to add float: left to .mode-bar-left.
On the topic of elegance, I strongly recommend that you consider some more semantically meaningful tags than just div. For example, .mode-bar-left is clearly a list (ul perhaps?) and the .mode-bar-item elements are clearly list items (li).
Are you using any javascript/jQuery? On a recent project of my own, I was having a similar issue and all I had to do was move my custom lightbox script from the to right before the tag, and it seemed to fix the issue. Sometimes javascript can be wonky like that. I don't understand why, but that's the way it is.