Issues with nesting CSS divs/boxes and overflow - css

Hi I'm just wondering if anyone can help me out. I'm new enough to web design, and I'm having some problems with my CSS.
Basically I cant figure out how to correctly nest my divs/boxes without having overflow issues! I have tried using overflow: hidden; but this still hasn't worked, I've also tried floating the child elements either left or right to see if it would help but still no luck!
My css looks like this:
#customerReg {
width: 47%;
height: 480px;
float: left;
background: #FFF;
padding: 10px 10px 10px 10px;
display: inline;
margin-top: 10px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
overflow: hidden;
}
#customerInfo {
width: 95%;
height: 120px;
background: #414141;
padding: 10px;
margin-bottom: 10px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
overflow: hidden;
}
#participantReg {
width: 47%;
height: 480px;
float: right;
background: #FFF;
padding: 10px;
margin-top: 10px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
overflow: hidden;
}
#participantInfo {
width: 95%;
height: 120px;
background: #414141;
padding: 10px;
margin-bottom: 10px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
overflow: hidden;
}
My HTML Is as follows:
<div class="contentbody" style="border:#FF0066 solid 2px;">
<div id="customerReg" style="border:#33CC00 solid 2px">
<div id="customerInfo">
<p>Customer Registration
</p>
</div>
<!-- End of customerReg --></div>
<div id="participantReg" style="border:#33CC00 solid 2px">
<div id="participantInfo">
<p>Participant Sign Up</p>
<p> </p>
</div>
<!-- End of participantReg --></div>
<!-- end .contentbody --></div>
What im aiming for is so have two rounded boxes side by side with two smaller boxes inside these boxes. I tried to post an image but it wouldnt let me! What im getting is that the two inner boxes are both spilling out on the right side of the outer boxes if that makes sense??
Can anyone tell me where im going wrong and what i can do to correct this as ive spent hours trying to find an answer and cant figure it out!

The parent div set:
overflow: hidden;
OR
#customerReg, #participantReg{
float:left;
}
.contentbody:after{
content: '.';
clear:both;
visibility: hidden;
*zoom:1;
height:0;
display:block;
}

if you set the width of the first div the boxes ar side by side:
look this fiddle
.contentbody{
width:990px;
border:#FF0066 solid 2px;
}

Related

chrome scrollbar behavior different on mac vs windows

Working on a grid-layout and I've run into a roadblock with css scrollbars differing between windows/mac.
Notice the scrollbar is to the right and away from the actual row. Now on windows, I see
Why is it that windows pushes the divs in the row to the next line? What is the best way to fix this?
General format in html is:
<div class="diamond-stat-body">
<div class="diamond-row">
<div class="diamond-block diamond-stat-block">
</div>
<div class="diamond-block diamond-stat-block">
</div>
...
</div>
....
</div>
and the corresponding css ...
.diamond-stat-block{
width: 125px;
height: 2.5em;
padding: .5em;
}
.diamond-block{
border: .1em solid white;
border-radius: 2px;
background-color: #ddd;
padding: 1em;
display: inline-block;
float: left;
}
.diamond-row{
height: 2.5em;
}
.diamond-body{
width: 480px;
height: 30%;
overflow-y: scroll;
margin: 0em auto;
}
Why don't you use an actual <table>?
If you don't want to do that, then what about using display: table; and display: table-cell;?
I haven't tested it, so I don't know whether that will fix your problem.

Issue placing div after facebook friends box

Every time I include the code for the facebook friends like box the div element box below it goes wacky. I cannot control where its positioned. It either disappears or overlaps a different div. Originally I just wanted specials, events, then fbFriends in a row then the box div below the three divs. I have been trying to wrap the divs to control everything better but am still unsuccessful. Any help would be appreciated
specials events fbFriends
box -------------------box
<div id="specialsWrapper">
<div id="specials" ><p>Featured Specials</p></div>
<div id="events" ><p>What's happening at the hub</p></div>
<div id="fbFriends">
<div class="fb-like-box"
data-href="https://www.facebook.com/pages/********"
data-height="395" data-width="250" data-show-faces="true"
data-colorscheme="dark" data-stream="false" data-header="true" />
</div>
</div>
</div>
<div id="box" ></div>
#specialsWrapper
{
height: 450px;
width: 920px;
color: white;
}
#specials {
float: left;
border:2px dashed white;
height:390px;
width: 270px;
color: white;
margin: 25px 10px 0px 48px;
}
#specials p {
margin: 0px;
padding: 15px;
text-transform:uppercase;
font-size: 24px;
font-style: oblique;
}
#events {
float: left;
border:2px dashed white;
height:390px;
width: 270px;
color: white;
margin: 25px 15px 15px 15px;
}
#events p {
margin: 0px;
padding: 15px;
text-transform:uppercase;
font-size: 24px;
font-style: oblique;
}
#fbFriends {
float: left;
margin: 25px 15px 15px 15px;
width: 250px;
height:390px;
}
#box
{
clear: left;
border: 2px dashed white;
height: 60px;
width: 853px;
color: white;
margin: 25px 15px 15px 48px;
}
Here's anwser for your question
EXAMPLE ON CODEPEN
Your build of these box's is weird thats why I had to use top: 40px; with position: relative;
btw. that's how you do on jsfiddle or codepen exampl, thats all community ask. Spend 5 min for your question isnt much to ask?
hope thats help.
EDIT:
I found what what the issue, you didnt closed specialsWrapper div thats why margin dint work.
I also cancel margin-botton from boxes inside specialWrapper and put overflow: auto to specialWrapper to countheight.
Now top: no need to be writen.
I think what you might want it display: inline-block; but without something to see I can't really know what's going on. And your description isn't enough. Could you post what's going on on js.fiddle.net or give us an example site?

Google Chrome and the Z-Index bug

I have been playing with a responsive site, and when all the menus and logos worked well in Coda, sliding nicely into place I tried the site in Chrome, and the logo seems to be hiding behind the header - any help gratefully received!
HTML
<div id="menu">
<div class="menu">
<ul>
<li>Prices</li>
<li>About</li>
<li>Contact</li>
<li class="contact"><span>✆</span> 0783 448 5449</li>
</ul>
</div>
</div>
<div class="container">
<div class="sixteen columns">
<div id="track">
<div class="logo"><img src="images/logo-120.png"></div>
</div>
</div>
CSS:
#menu {
position: fixed;
top: 50px;
height: 50px;
background-color: rgba(255,255,255,0.9);
width: 100%;
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc;
-moz-box-shadow: 0 0 5px #888;
-webkit-box-shadow: 0 0 5px#888;
box-shadow: 0 0 5px #888;
text-align: center;
z-index: 3000;
}
.menu ul li {
display: inline-block;
margin-left: auto;
margin-right: auto;
margin-top: 12px;
text-align: center;
vertical-align: middle;
padding: 2px 4px 2px 4px;
background-color: #fff;
font-size: 130%;
}
#track {
position: fixed;
top: 1px;
}
.logo {
position: relative;
height: 120px;
width: 153;
top: 20px;
left: 0px;
z-index: 3500;
}
Not sure if this should be called a "bug" per-se.... it's just the way the browser handles the relationships between parent/child elements and the z-index property.
The problem is the #menu is a sibling to the .container element, not the .logo.
It doesn't matter how high you put the z-index on .logo it won't go in front of the #menu because the .logo's parent (.container) will always be behind the #menu....
.container has no position or z-index
If that makes no sense, I understand. You might get a better idea from this jsFiddle http://jsfiddle.net/EpgxK/1/ and check this out as well http://css-tricks.com/almanac/properties/z/z-index/.
Oh, and you'll probably have to recode your html if you want the menu to appear in front of the logo at smaller screen sizes.
The position: fixed header needs to have a z-index of 0 (or negative) for the logo to appear above it. I think you may be missing some styles to see this problem based on what you have given us, though.
http://jsfiddle.net/ExplosionPIlls/MaDe2/1/
I Had a same issue I solve by just giving position:static instead position:relative.
In your case just change this class.
`
.logo {
position: static;
height: 120px;
width: 153;
top: 20px;
left: 0px;
z-index: 3500;
}`

Trying to get a div next to my image

Can't post this on jsfiddle since it seems down.
div.browseBuildsArea-pro
{
float: left;
position: relative;
width: 790px;
height: 90px;
background-image:url('../images/builds/builds-bg-pro.jpg');
background-repeat:no-repeat;
}
div.browseBuildsArea-pro img.champion
{
display: block;
height: 72px;
margin-left: 14px;
margin-top: 7px;
border-radius: 9px;
-moz-border-radius: 9px;
-khtml-border-radius: 9px;
-webkit-border-radius: 9px;
}
div.browseBuildsArea-pro div.build-poster
{
display: block;
position: relative;
margin-left: 150px;
margin-top: 10px;
}
<div class="browseBuildsArea-pro">
<img class="champion" src="<%THEME%>images/lol/avatars/2.png">
<div class="build-poster">
awdwada
</div>
</div>
I'm new to CSS so I need help on two things.
Is there any overuse of attributes in my styling?
"build-poster" div always goes under image. How can I get it on right side of image?
Thanks alot!
You don't need to specify position:relative on <div> since you are not using any left, top, right and bottom properties on those divs. However it's a good idea for older browsers such as IE7.
you need to add float:left to img.champion class
You need to float the image, add:
div.browseBuildsArea-pro img.champion {
float: left;
}

Trying to get my divs in a centered line. What am I doing wrong?

CSS
div.browseBuildsArea-pro {
float: left;
position: relative;
width: 790px;
height: 90px;
background-image:url('images/builds/builds-bg-pro.jpg');
background-repeat:no-repeat;
}
div.browseBuildsArea-pro img.champion {
float: left;
display: block;
height: 72px;
margin-left: 14px;
margin-top: 7px;
border-radius: 9px;
-moz-border-radius: 9px;
-khtml-border-radius: 9px;
-webkit-border-radius: 9px;
}
div.browseBuildsArea-pro div.build-poster {
float: left;
display: block;
margin-left: 10px;
margin-top: 10px;
}
div.progress-for-build-listing {
float: left;
width: 250px;
margin-left: 400px;
margin-top: 0px;
}
HTML
<div class="browseBuildsArea-pro">
<img class="champion" src="<%THEME%>images/lol/avatars/2.png">
<div class="build-poster">
Test Message
</div>
<div class="progress progress-for-build-listing">
<div class="progress-bar" style="width: 100%;"></div>
</div>
</div>
What I am trying to achieve is basic.
I want "Test Message" content be aligned to the middle of the div automatically. (regardless of the length of string) Also, "progress bar" and additional divs on the right side should also be automatically centered to the middle.
Here is a preview of what I'm looking for.
(Both divs and content inside divs are automatically aligned to the middle.)
Tried several things but none worked. (e.g display: table-cell;)
How can I achieve this? One little example will get me going.
To align text in the middle you need 2 parameters in your CSS.
display:table-cell;
vertical-align:middle;
Also your div is missing a height. you must add that to align it.
for your code it would be :
div.browseBuildsArea-pro div.build-poster {
float: left;
display:table-cell;
vertical-align:middle;
height:72px;
text-align:center; // if you also want it to align in the middle horizontally
margin-left: 10px;
margin-top: 10px;
}
For vertical alignment check out this article:
http://phrogz.net/css/vertical-align/index.html
And utilising what I saw from the above article: http://jsfiddle.net/tf7Cb/
This for the horizontal centering should you require it:
div.browseBuildsArea-pro div.build-poster {
float: left;
display: block;
margin-left: 10px;
margin-top: 10px;
text-align: center;
}

Resources