I'm having a little issue here. This is my HTML.
<div class="one">
</div>
<div class="two">
<ul class="ulclass">
<li>DASDA</li>
<li>QWEQW</li>
</ul>
</div>
This is my CSS:
.one{
width: 100%;
height: 300px;
background-color: black;
}
.two{
margin-top: 0px;
display: block;
padding: 0px;
margin-bottom: 0px;
}
.ulclass{
list-style-type: none;
margin:0px;
margin-bottom: 0px;
}
.ulclass li{
width: 500px;
padding: 10px;
overflow: auto;
float: left;
}
My problem is that these divs are next to each other and not above the other.
It looks like this.
http://oi57.tinypic.com/2lm5e1i.jpg
I want the green one to be down the black one. I have tried a lot of things and I can't do it.
I forget, these divs are inside another DIV which is a container
here the css:
.rost{
height: 100%;
min-height: 300px;
background-color: #fff;
padding: 0px;
padding-left: 0px;
box-shadow: 0 0 28px rgba(0, 0, 0, .6);
display: flex;
display: -webkit-box;
}
Here is the JSFIDDLE: http://jsfiddle.net/aemgm73z/
try adding clear:both; to .two class
.two{
clear:both;
margin-top: 0px;
display: block;
padding: 0px;
margin-bottom: 0px;
}
Remove display: -webkit-box and display: flex from your parent container.
As far as the second div goes it seems you've put the <li> elements within the <a> elements which is why they are spilling out of the divs. The child divs ARE in the parent divs but because you've enclosed the links the other way round the divs aren't expanding to wrap around them
You can see this point by assigning a fixed height, say 1000px to .lista div and upon inspection find that .rost does enclose both the divs.
Swapping the li and a tags should work for you.
Do you have any specific reason to include float: left into your css? After removing that, things are working as you expect.
.one{
width: 100%;
height: 300px;
background-color: black;
}
.two{
margin-top: 0px;
display: block;
padding: 0px;
margin-bottom: 0px;
background-color: green;
}
.ulclass{
list-style-type: none;
margin:0px;
margin-bottom: 0px;
}
.ulclass li{
width: 500px;
padding: 10px;
overflow: auto;
}
<div class="one">
</div>
<div class="two">
<ul class="ulclass">
<li>DASDA</li>
<li>QWEQW</li>
</ul>
</div>
Remove disply:block and margin-top:0px property from your style
Try adding display:block; to your .one style, this will make the green div bump down onto the next line.
Related
the following is my CSS code:
.portrait
{
width: 400px;
position: relative;
display: inline-block;
background-color: #4E5555;
}
.portrait img
{
width: 150px;
float: left;
padding-right: 20px;
}
.portrait h4
{
text-align: left;
margin: 0px 0px 0px 0px;
color: #fff;
}
And the following is my relevant html code:
<div class="portrait">
<img src="images\filmmakers\Aboui, Julian\JulianAboui-web.jpg">
<h4>Julian Aboui</h4>
</div>
<div class="portrait">
<img src="images\filmmakers\Alter, Aaron\AaronAlter-web.jpg">
<h4>Aaron Alter</h4>
</div>
<div class="portrait">
<img src="images\filmmakers\Abrahams, Pia\PiaAbrahams-web.jpg">
<h4>Pia Abrahams</h4>
<h4>STUFF STUFF STUFF STUFF STUFF STUFF STUFF STUFF STUFF STUFF STUFF</h4>
</div>
<div class="portrait">
<img src="images\filmmakers\Asnani, Shailen\ShailenAsnani-web.jpg">
<h4>Shailen Asnani</h4>
</div>
My output is the following:
http://i.imgur.com/YRkJvmn.png
I think I know what the problem is, but I'm not sure how to fix it. The last container element (on the bottom right) is placed further down because it thinks it is under the text. Is that correct? I'm unsure how to fix that.
Any help is appreciated, thank you!
Divs are finicky. I would recommend using ul with display:block inline. Just look at the page source of a web site where you can see something like that working. A snippet from my css where it works (I have a div inside the li withe text and multiple images)
div.list_holder {margin-bottom: 10px; clear: both; font-style:normal;}
ul.user_list {display:block; margin: 0px auto;}
li.list_item {list-style: outside none none; margin-right: -100%;
position: relative; padding: 0px; clear: none;
margin-bottom: 10px !important;
border: 2px solid !important; min-height: 325px;
max-width: 206px; float: left; margin-right: -100%;
width: 23.5%;border-radius: 2px;}
Not sure but a simple solution would be to display it as a table
.row {
display:table-row;
}
.portrait
{
width: 400px;
position: relative;
display: table-cell;
background-color: #4E5555;
}
.portrait img
{
width: 150px;
float: left;
padding-right: 20px;
}
.portrait h4
{
text-align: left;
margin: 0px 0px 0px 0px;
color: #fff;
}
And wrap the two rows you want in <div class='row'>
In my opinion for positioning these kind of containers you don't need to sue postion: relative if you have a bigger contaner/wrapper, which wraps the portraits and it is positioned via margins. In that case you can use margin to position your container. Also It is a good idea to use figure tag for the images if you want to style them little bit better and make them display: block if you want the text to be under the image.
I'm almost sure this is going to be a clear: both answer, but the trouble I'm having is where to put it, or how to wrap my head around understanding it.
I have divs within divs, and this particular one (sectioncut) is taking into consideration the height of its cousin ul (subnav). I've tried encapsulating the ul in its own div, but I must not understand how position and clear works yet.
This is my first time posting on Stackoverflow, so any feedback is welcome =D
http://jsfiddle.net/JustJinxed/d62eLh4o/
HTML
<div id="pagecut">
<div id="pagebg">
<div id="nav">
<ul id="subnav">
<li>Home</li>
<li>About</li>
</ul>
<div id="sectioncut">
This is a test.
</div>
</div>
</div>
</div>
CSS:
body,html {
border: 0px;
margin: 0px;
height: 100%;
background-color: #2200FF;
}
#pagecut {
width: 95%;
height: 100%;
margin-right: auto;
margin-left: auto;
margin-top: 0;
margin-bottom: 0;
background-color: #2200FF;
outline-style: solid;
outline-color:#FF0004;
}
#pagebg {
width: 100%;
height: 100%;
margin-left: auto;
margin-right: auto;
background:url(Img/bg1.png);
background-size: 100% auto;
background-repeat:no-repeat;
}
#nav {
width: 98%;
height: 100%;
margin-right: auto;
margin-left: auto;
outline-style: solid;
outline-color:#00FF00;
}
#subnav {
margin: 0px;
padding: 0px;
}
#subnav li {
display:inline;
background-color: #7DA5EB;
border-color: #7DA5EB;
color: #FFF;
border-top-right-radius: 7px;
border-top-left-radius: 7px;
border-style: solid solid none;
padding-right: 7px;
padding-left: 7px;
margin-left: 2px;
margin-right: 2px;
font-size: x-large;
}
#sectioncut {
height: 100%;
background-color: #7DA5EB;
}
If I understand correctly, your problem is that #sectioncut is overflowing its container because it is taking the whole container's height and being pushed down by the other div (#subnav) inside the container.
If that's the problem and you want to fill only the space left by the subnav div, I think How can I make a DIV take up the rest of the height of a container div? will help you.
It's my first time answering aswell so I hope I did it right and this was helpful to you.
I'm having problems making my site look good in Firefox. I have a div and then two divs inside the first one and I want the two that are inside two be side by side. This is the HTML:
<div class="gluggi3">
<h2 class="aust">Veðurspá</h2>
<div class="vedurspa">Some content</div>
<div id="map-canvas">More content</div>
</div>
and then the CSS:
.gluggi3{
background-color: rgba(0,0,0,0.5);
padding: 10px;
margin: 10px;
border: solid;
border-color: magenta;
border-radius: 10px;
width: 100%;
}
.vedurspa {
display: block;
width: 50%;
float: left;
padding-right: 50px;
}
#map-canvas {
height: 300px;
width: 300px;
margin: 0px;
padding: 0px;
display: block;
}
This code works fine in Chrome but not in Firefox, in Firefox the div with the class 'vedurspa' dissappears. I tried using inline, inline-block and initialising left like suggested in other questions, but still no luck. Can anyone tell me how I can make them stay side by side in Firefox? Thanks in advance!
you have a padding-right: 50px; on .vedurspa, therefor they are not side by side, removing that would solve your problem
It's not a FireFox issue. When the viewport is to narrow, #map-canvas will start wrapping.
Consider this:
.gluggi3{
background-color: rgba(0,0,0,0.5);
padding: 10px;
margin: 10px;
border-color: magenta;
border-radius: 10px;
width: 100%;
}
.vedurspa {
width: 50%;
padding-right: 50px;
float: left;
}
#map-canvas {
height: 300px;
width: 100px;
margin: 0px;
padding: 0px;
float: left;
}
Fiddle: http://jsfiddle.net/vUvhq/
Also, remove your comma in the first .gluggi3 class
.gluggi3,{}
to
.gluggi3{}
I'm assuming you added the padding-right to .verdurspa so there would be space between the blocks.
Try adding float: right; to #map-canvas
I have been stuck with this div in the header wrapping to the next line when the window is resized. You can view it at http://www.commexfx.com . The right div in the header which includes the search box etc is wrapped to the next line when resizing the window. I tried everything: changing position, display, white-space, etc, but nothing. the structure is like this:
<div id="header">
<div id="logo"> </div>
<div class="top-widget"></div>
</div>
And the CSS code for the time being is:
#header {
margin: 0 auto;
/* max-width: 960px; */
width: 960px !important;
height: 100px !important;
border: 1px solid blue;
background-color: #ffffff;
white-space: nowrap !important;
}
#logo {
float: left;
z-index: 9999999;
margin-bottom: 20px;
width: 360px;
display: inline;
border:1px solid green;
padding: 0 !important;
margin: 0 !important;
}
.top-widget {
background: none;
border: none;
/*clear: right;*/
float: right;
height: 95px;
text-align: right;
display: inline;
width: 590px !important;
border: 1px solid yellow;
padding: 0 !important;
margin: 0 !important;
}
Would appreciate any help. Also searched the forums here and tried every possible solution I could find but nothing.
Thanks
Add min-width:960px to your css #header declaration.
Replace your css with these new ones. Floating two elements, one right and one left will make them wrap so I would use inline-block.
You don't need position:relative unless you are positioning elements within that div as absolute so you can remove those as well. Same with z-index.
Also, you don't need !important unless you have other styles overriding this. I try and use it sparingly.
#header {
margin:0 auto;
width:960px;
}
#logo {
margin-bottom: 20px;
width: 360px;
display: inline-block;
}
#logo img {
vertical-align: inherit;
}
.top-widget {
text-align: right;
width: 570px;
display: inline-block;
}
I see that when we use table + tr + td we never see inner elements outside of outer elements.
But in case of Divs it can be.
Now I see that my inner div is located outside of parent div.
How to control child divs? What is wrong in my html?
I mean I have next html and I see that child div is outside of the parent
<div id="page">
<div id="main">
<div id="djInfo">
</div>
<div id="footer">
</div>
</div>
</div>
#page
{
width: 100%;
margin-left: auto;
margin-right: auto;
height: 100%;
position: relative;
}
#main
{
padding: 0px 0px 0px 0px;
background-color: #0c1114;
margin-bottom: 30px;
_height: 1px; /*only IE6 applies CSS properties starting with an underscore */
text-align: center;
height: 100%;
position: relative;
}
#footer
{
color: #999;
padding: 0px 0;
text-align: center;
line-height: normal;
margin: 0;
font-size: .9em;
background-image: url('img/BottomGradient.jpg');
background-repeat:repeat;
height: 160px;
width: 100%;
float: left;
}
#djInfo
{
float: left;
position: relative;
margin-left: 250px;
}
I kinda constructed what you posted and everything seems to work fine?
http://jsfiddle.net/XrDTe/
But please, double check your code, there are some redundancies in it.
(Why give something with 100% width margin-left/right: auto? Why all the float: left's and the position: relative's? Why the IE6 height of 1px? All of this is not necessary and may hinder you in writing decent, to-the-point CSS)