I need help with css, I have this setup:
<div class="embedInner">
<div class="embed_code"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris et sapien. Quisque risus. Ut laoreet hendreri mi.</p></div>
<div class="copy"><p>COPY</p></div>
</div>
http://jsfiddle.net/h7u8J/11/
I want both child divs always to stay in single line, both left and right, and text in embed_code to be overflow:hidden and not to fall into new line, so if space become smaller than width of the parent div.
If you will provide certain width to the parent div and the embedded div, then you can achieve what you want.
.embedInner{
position:absolute;
/*background: #333;*/
width: 100%; // newly added
}
.embed_code{
float:left;
background: #333;
overflow:hidden;
width: 90%; // newly added
}
.embed_code p{
padding:5px;
margin:0;
color:#fff;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
}
.copy {
background: #ddd;
float:right;
}
.copy p{
padding:5px;
margin:0;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
float:right;
}
Please check if it can help you. Thanks :)
i changed your code!
i think this is what you want! DEMO
CSS:
.embedInner{
display:inline-block;
position:relative;
width:100%;
/*background: #333;*/
}
.embed_code{
position:relative;
left:0;
width:90%;
display:inline-block;
float:left;
background: #333;
overflow:hidden;
}
.embed_code p{
padding:5px;
margin:0;
color:#fff;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
display:inline-block;
white-space: nowrap;
}
.copy{
display:inline-block
background: #ddd;
float:right;
position:relative;
right:0;
width:10%;
background:green;
text-align:center;
}
.copy p{
padding:5px;
margin:0;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
float:right;
}
HTML:
<div class="embedInner">
<div class="embed_code">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris et sapien. Quisque risus. Ut laoreet hendreri mi.
</p>
</div>
<div class="copy"><p>COPY</p></div>
</div>
Related
Css beginner asks!!When i try to hover the text which have position absolute, hover is gone.Could not solve it.Maybe z index solve the problem but i could not make it.Thanks for your helps in advance.
Fiddle
*{
padding:0;
margin:0;
}
body {
background:#eee;
font-family:helvetica;
font-weight:bold;
}
.news {
position:relative;
left:50%;
margin-left:-300px;
margin-top:50px;
width:600px;
height:300px;
border-top:3px solid #f26222;
overflow:hidden;
z-index:1;
}
.news img {
cursor:pointer;
}
.text {
position:absolute;
top:85%;
transition:all 0.3s ease;
}
.text h2 {
margin-bottom:20px;
text-align:center;
}
.text p {
margin-left:10px;
margin-right:10px;
font-weight:normal;
}
.news img:hover + .text {
top:65%;
}
span {
position:absolute;
top:0;
background:#f26222;
color:#eee;
padding:3px;
}
<div class="news">
<span>Technology</span>
<img src="http://i.imgur.com/YlkCC9u.jpg" height=300 , width=600>
<div class="text">
<h2>LOREM IPSUM ETIAM EST</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat</p>
</div>
</div>
Replace
.news img:hover + .text {
top:65%;
}
with
.news:hover .text {
top:65%;
}
Try this.
<div class="news">
<span>Technology</span>
<img src="http://i.imgur.com/YlkCC9u.jpg" height=300 , width=600>
<div class="text">
<h2>LOREM IPSUM ETIAM EST</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat</p>
</div>
</div>
*{
padding:0;
margin:0;
}
body {
background:#eee;
font-family:helvetica;
font-weight:bold;
}
.news {
position:relative;
left:50%;
margin-left:-300px;
margin-top:50px;
width:600px;
height:300px;
border-top:3px solid #f26222;
overflow:hidden;
}
.news img {
cursor:pointer;
}
.text {
position:absolute;
top:85%;
transition:all 0.3s ease;
}
.text h2 {
margin-bottom:20px;
text-align:center;
}
.text p {
margin-left:10px;
margin-right:10px;
font-weight:normal;
}
.news:hover .text {
top:65%;
}
span {
position:absolute;
top:0;
background:#f26222;
color:#eee;
padding:3px;
}
--Edit--
JSFiddle
Beginner doubt: I would like to hide the parent div when the child div is visible. Is this possible to do with css? maybe using the z-index?
Another thing, Can I format the child div with different css atributes, or they need to be the same ones of the parent?
Thanks!
<!doctype html>
<style type="text/css">
#intro {
width:100%;
float:left;
padding-top:3%;
background-repeat:no-repeat;
background-size:100%;
position:relative;
z-index:50;
}
.wrapper_intro {
display:block;
width:38%;
margin: 7% 3% 3% 7%;
float:right;
color:black;
padding:3% 3% 4% 3%;
background-color:none;
position:absolute;
z-index:100;
right: 0px;
}
.parent {
display:block;
font-size:5em;
color:yellow;
margin-top: 2%;
margin-bottom:3%;
text-align:center;
z-index: 102;
}
.child {
display:none;
}
.parent:hover .child {
display:block;
background-color: rgba(242, 218, 192, 0.9);
margin-top:5%;
color:black;
text-align:center;
z-index: 101;
}
</style>
<div class="wrapper_intro">
<div class="parent">
<div>Ola!</div>
<div class="child">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</div>
</div>
When you hide a parent div, all elements inside it also will get hidden.
Didn't understand ur scenario. If you want them to be separate, don't nest them in a div. Keep them separate.
Yes the css can be different for parent and child. You can use !important to over ride any css already used for parent.
Due to comment it should be quite simply, what about adding just
.parent:hover > div:first-child {visibility: hidden}
http://jsfiddle.net/czd1z5jh/
OR if you want to move .child to the top:
.parent:hover > div:first-child {display: none}
http://jsfiddle.net/czd1z5jh/1/
See demo and source CSS+HTML (via view source) at http://arcane-earth-5322.herokuapp.com/
Driving me nuts trying to get the button and search box to be the exact same height, same position (horizontally aligned) and same font. I have got it close, but no cigar.
Zoom in 200% to see the difference in height. The search box is 1-2px taller and looks to be fractionally lower on the page.
I also don't understand why the computed font sizes for the button and search box are different at most zoom levels (inc. 100%).
EDIT: Adding the code below:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1" />
<title>Responsive Test</title>
<style type="text/css">
body {
color:#555;
font-family:'Helvetica Neue';
font-size:110%;
line-height:140%;
margin:0;
padding:0;
-moz-background-size:cover;
-webkit-background-size:cover;
background-size:cover;
background:url(http://d7mj4aqfscim2.cloudfront.net/images/landscapes/duo-land_mv_c9ad01b8dcb245a1140bd5cb57158ba6.jpg) no-repeat center center fixed;
}
#header1 {
background-color:#60affe;
color:#fff;
text-align:center;
padding:10px 0px;
margin:auto;
}
#header2 {
background-color:#8fc7fe;
color:#fff;
text-align:center;
padding:10px 0px;
margin:auto;
}
#content {
margin-left:auto;
margin-right:auto;
background-color:#fafafa;
border:1px solid #ddd;
}
#content-content {
clear:both;
padding:5%;
}
#button-container {
float:left;
margin-top:15px;
text-align:center;
width:100%;
}
.button {
display:inline-block;
margin:10px;
padding:10px;
background-color:#efefef;
border:1px solid #ccc;
border-radius:2px;
color:#555;
max-width:220px;
min-width:220px;
}
.search {
display:inline-block;
}
.search_box {
margin:10px;
padding:10px;
border:1px solid #ccc;
border-radius:2px;
max-width:220px;
min-width:220px;
color:#555;
font-family:'Helvetica Neue';
font-size:110%;
line-height:140%;
font-weight:200;
}
#media (min-width: 1024px) {
#header1 { width:50%; }
#header2 { width:50%; }
#content { width:50%; }
}
#media (min-width: 768px) and (max-width:1023px) {
#header1 { width:80%; }
#header2 { width:80%; }
#content { width:80%; }
}
#media (max-width: 767px) {
#header1 { width:100%; }
#header2 { width:100%; }
#content { width:100%; }
body { font-size:140%; }
}
</style>
</head>
<body>
<div id="header1">Header 1</div>
<div id="header2">Header 2</div>
<div id="content">
<div id="button-container">
<div class="button">
Button 1
</div>
<div class="search">
<input class="search_box" name="search" placeholder="Search..." />
</div>
</div>
<div id="content-content">
<p>
Etiam at purus id ipsum sodales vehicula. Nam purus nunc, luctus ut laoreet et, pharetra eget est. Nulla
nisi tellus, euismod vel hendrerit dignissim, egestas eget ante. Morbi pellentesque, tellus ut adipiscing
vestibulum, purus orci gravida felis, sit amet rhoncus quam nulla non massa. Sed volutpat porttitor lectus
accumsan hendrerit. Donec lectus urna, euismod ut accumsan ac, congue in risus.
</p>
</div>
</div>
</body>
</html>
.search_box {
margin: 10px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 2px;
max-width: 220px;
padding-top: 11px;
min-width: 220px;
color: #555;
height: 24px;
font-family: 'Helvetica Neue';
font-size: 110%;
line-height: 140%;
font-weight: 200;
}
and why this div around the search box? It's not the best practice to have a div element inline with something else.
Set the font-size: 110%; to the button as well.
Good Day Im new to CSS
And recently after I have finish my first project, an extra white space came up on my page, Then I have found out that the hr tag that I am using is one reason why there an extra white space(I guess?) , when I put hr size
#hr{
width:960px;
margin: 0px auto;
color:#C0C0C0;
height: 12px;
margin-bottom:15px;
overflow:hidden;
}
white page will appear
But when I put
#hr {
width:70%;
margin: 0px auto;
color:#C0C0C0;
height: 12px;
margin-bottom:15px;
overflow:hidden;
}
This will be ok but zooming it in/out will move the hr line,
If needed I'll post the codes but my codes is so many...
Right, I think ill put my codes,
HTML CODES:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Beginner</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
</style>
</head>
<body>
<div id="top-most">
</div>
<div id="wrapper">
<div id="logo">
<img alt="logo" src="images/logo.png" />
</div>
<div id="header">
<p>info#CreativeStudio.com</p>
</div>
<div id="top-bar-selection" >
<ul>
<li>HOME</li>
<li> ABOUT US </li>
<li> PORTFOLIO </li>
<li> SERVICES </li>
<li> BLOG </li>
<li> CONTACT US </li>
</ul>
</div>
</div>
<hr id="hr" />
<div id="banner">
<object id="flash1" data="Beginner.swf" type="application/x-shockwave-flash" style="width: 960px; height: 380px">
<param name="movie" value="Beginner.swf" />
</object>
</div>
<div id="hr2">
<hr />
</div>
<div id="information">
<div id="about-us-section">
<div id="about-us">
<h3>→ ABOUT US</h3>
</div>
<div id="hr">
<hr />
</div>
<div id="content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis nulla id orci malesuada porta posuere quis massa. Nunc vitae purus non augue scelerisque ulitricies vitae et velit. Sed vitae lectus id sem lobortis scelerisque. Praesent eget consequat libero.</p>
<p style="height: 3px"></p>→<h4>Read</h4>
</div>
</div>
<div id="our-benefits-section">
<div id="our-benefits">
<h3>→ OUR BENEFITS</h3>
</div>
<div id="hr">
<hr />
</div>
<div id="content">
<p>☑Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis nulla id orci malesuada porta posuere quis massa. </p>
<p>☑ Nunc vitae purus non augue scelerisque ulitricies vitae et velit. Sed vitae lectus id sem lobortis scelerisque. Praesent eget consequat</p>
<p>☑Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis nulla id orci malesuada porta posuere quis massa. </p>
</div>
</div>
<div id="testimonials-section">
<div id="testimonials">
<h3>→ TESTIMONIALS</h3>
</div>
<div id="hr">
<hr />
</div>
<div id="content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis nulla id orci malesuada porta posuere quis massa. Nunc vitae purus non augue scelerisque ulitricies vitae et velit. Sed vitae lectus id sem lobortis scelerisque. Praesent eget consequat libero.</p>
<h5>Rafi, Graphicsfuel.com</h5></div>
</div>
</div>
<div id="hr">
<hr />
</div>
<div id="our-portfolio-section">
<div id="our-portfolio">
<h3>→ OUR PORTFOLIO</h3>
</div>
<img alt="PortfolioA" src="images/Portfolio A.jpg" id ="picA" />
<img alt="PortfolioB" src="images/Portfolio B.jpg" id ="picB"/>
<img alt="PortfolioC" src="images/Portfolio C.jpg" id ="picC"/>
<img alt="PortfolioD" src="images/Portfolio D.jpg" id ="picD"/>
</div>
<div id="hr">
<hr />
</div>
<div id="information2">
<div id="blog-updates-section">
<div id="blog-updates">
<h4>→ BLOG UPDATES</h4>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis nulla id orci malesuada porta posuere quis massa. Nunc vitae purus non augue scelerisque ulitricies vitae et velit. Sed vitae lectus id sem lobortis scelerisque. Praesent eget consequat libero.</p>
</div>
</div>
<div id="socialmedia">
<h6> → CONNECT WITH US</h6>
<img alt="" src="images/Icon/Twitter.png" />
<img alt="" src="images/Icon/Facebook.png" />
<img alt="" src="images/Icon/Flickr.png" />
<img alt="" src="images/Icon/RSS.png" />
</div>
</div>
<div id="footerbgcolor">
<div id="footer">
<div class="below-bar-selection">
<p>Home | About Us | Portfolio | Services | Blog | Contact Us</p>
<p>© 2010 CreativeStudio. All Rights Reserved</p>
</div>
<div class="logo-small" style="left: 770px; top: 1240px; width: 128px">
<img alt="" src="images/Icon/Logo%20Small.png" />
</div>
</div>
</div>
</body>
</html>
CSS CODES:
#top-most { background-color:black; height:17px; }
#wrapper { width :960px; height:130px ; margin:0px auto; background-color: #F4F4F4; overflow:hidden; }
#logo { margin: 19px 0 0 10px; float:left; }
#header { float: right; margin: 19px 3px 0 0; }
#header p { color: #979899; }
#top-bar-selection { width:960px;position :absolute ; overflow:hidden; display:inline-block; margin:70px auto 0 -160px; word-spacing:1px; letter-spacing:1px;}
#top-bar-selection ul{color:orange; text-align: right; }
#top-bar-selection ul li {display :inline; font-size:12px; font-family: arial black; margin: 0 32px 0 0;}
#top-bar-selection ul li a:link {color: #fe9a00; font-family: Arial black; }
#top-bar-selection ul li a:hover {color: #000000; font-family: Arial black; }
#hr { width: auto; margin: 0px auto; color:#C0C0C0; height: 12px; margin-bottom:15px; overflow:hidden;}
#hr2 { width:960px; margin: 0px auto ; margin-top:10px; height:9px;}
#banner { width:960px; height:380px ; margin:0px auto; background-color: black; }
#information { width:960px; margin :0px auto 0 auto; height:235px; padding-top : 15px; margin-top:13px; }
#about-us-section { width: 266px; margin-right: 600px; background-color: #F4F4F4; position:absolute; padding-right: 10px; }
#about-us-section hr { background-color:black; height:7px; width:260px; margin:10px 0 0 0; position:absolute; }
#about-us-section p { padding-top: 10px; font-weight:lighter;}
#about-us-section h4 { color:#FF9933; display:inline; line-height:30px;}
#about-us-section h4 a:link {color: #fe9a00; font-family: Arial black; }
#about-us-section h4 a:active {color: #fe9a00; font-family: Arial black;}
#about-us-section h4 a:visited {color: #fe9a00; font-family: Arial black;}
#about-us-section h4 a:hover { color:#000000; }
#our-benefits-section { width: 270px; margin: 0 0 0 355px; background-color : #F4F4F4; position:absolute; padding-right: 10px;}
#our-benefits-section hr { background-color:black; height:7px; width:260px; margin:10px 0 0 0; position:absolute; }
#our-benefits-section p { padding-top: 10px; }
#testimonials-section { width: 270px; margin: 0 0 0 700px; position:absolute; padding-right: 10px; }
#testimonials-section hr { background-color:black; height:7px; width:260px; margin:10px 0 0 0; position:absolute; }
#testimonials-section p { padding-top: 10px; font-weight:300; }
#testimonials-section h5 { padding-top: 10px; font-style:italic; }
#our-portfolio-section { width:960px; margin: 0px auto 0 auto; display: block; height:205px; }
#our-portfolio-section our-portfolio { margin: 5px 2px 0 0; }
#our-portfolio-section img { padding: 15px; display:inline;}
#information2 { width:960px; margin :0px auto 0 auto; height:145px; margin-top:5px; }
#blog-updates-section { width:600px; height:50px; position:absolute; }
#blog-updates-section h3 {margin: 8px 5px 0 0; line-height:10px;}
#blog-updates-section p {margin: 28px 5px 0 0; }
#blog-updates .content { margin: 28px 5px 0 0; float:left; position:absolute;}
#socialmedia { float:right; overflow:hidden; position:absolute;margin: 10px 720px; width: 150px; height: 125px; width:200px;}
#socialmedia h6 { font-size:10px;}
#socialmedia img { padding: 6px; margin-top:20px; }
#footerbgcolor { background-color:#E2E2E2; height:100px; }
#footer { width :960px; height:100px ; overflow:hidden; margin:0px auto; }
#footer .below-bar-selection { margin: 30px 0 0 20px; float:left; width: 750px; }
#footer a:link {color: #000000; font-family: Arial black; }
#footer a:active {color: #000000; font-family: Arial black;}
#footer a:visited {color: #000000; font-family: Arial black;}
#footer h4 a:hover { color:#000000; font-family:Arial black;}
#footer .logo-small { float:right; padding-top: 15px;}
If you already got a better solution, then forget this message,
But i noticed something.
according to your code
#hr {
width: auto;
margin: 0px auto;
color:#C0C0C0;
height: 12px;
margin-bottom:15px;
overflow:hidden;}
Since your id of Wrapper is 960 pixels,
use that width template to set your HR' width value.
so change:
width: auto;
to
width: 958px;
Notice: 960px looks a bit too long, so i shaved some pixels out to fit the alignment. But if 960 looks better, then choose 960.
Well first of all i don't see any white space on right side of the page rather space between the hr tag due to the height you have given.
Secondly,
hr tag will automatically create a line. If you want to give it an id that means you want to add additional styling to the hr element.
If i am understanding properly, than you shouldn't even use WIDTH.
#hr{
// no need to use width as it will automatcally fill it self
margin: 0px auto;
color:#C0C0C0;
height: 12px; // only needed if you want to create space inbetween
margin-bottom:15px;
overflow:hidden;
}
and use it as
<hr id="hr" />
Hope this answers your question.
Since you only posted the CSS code without the HTML code, it may be hard for people to see the whole problem, but from the information you posted, this will be my proposed solution,
This css code:
width:960px;
makes your HR a fixed width of 960 pixels.
This css code:
width:70%;
makes your HR take up 70% of its container's width.
You could just try setting the width to 100%.
p.s. Why do you need it to be 70% ?
hr { //remove # so it will apply to <hr> tag
width:70%;
margin: 10px auto; // change the margin size so the hr line can be seen
color:#C0C0C0;
margin-bottom:15px;
overflow:hidden;
}
I think the problem that could remove the hr line is only about margin. If the margin is set to 0, then the hr line could be override by another tag
I think this is because I'm floating all three divs "columns" to the left, inside of the main body div.
How can I tell the main body div to expand as big as it needs to fit the content divs?
Here it's with min-height:
And here with the min-height taken away:
Here is my relevant code.
#body
{
border:1px solid blue;
width:950px;
margin-left:auto;
margin-right:auto;
margin-top:15px;
}
#leftcolumn
{
min-height:500px;
float:left;
width:190px;
}
#contactarea
{
font-family:Arial;
}
#contactarea p.heading
{
Color:#000;
font-size:large;
position:relative;
left:14px;
}
#contactarea p.tag
{
color:#000;
font-size:medium;
position:relative;
left:10px;
}
#leftnavigation ul
{
margin:0;
padding: 0;
list-style: none;
}
#leftnavigation ul li {
border-top: 1px solid #333;
border-bottom: 1px solid #111;
}
#leftnavigation ul li:first-child {border-top: none;}
#leftnavigation ul li:last-child {border-bottom: none;}
#leftnavigation ul li a
{
padding: 10px;
display: block;
color: #fff;
background-color:#222222;
text-decoration: none;
}
#leftnavigation ul li a:hover {background: #111;}
#contentarea
{
border:1px solid blue;
min-height:500px;
float:left;
width:594px;
margin-left:5px;
margin-right:5px;
}
#advertisingarea
{
width:150px;
float:left;
min-height:500px;
background-image:url('images/advertisingAreaBackground.png');
background-repeat:repeat-y;
}
.advert
{
height:190px;
overflow:hidden;
}
.advert img
{
padding:0;
margin:0;
position:relative;
left:25px;
top:5px;
}
.advert p
{
font-size:x-small;
font-family:Arial;
margin-left:8px;
margin-right:8px;
margin-top:5px;
}
<div id="body">
<div id="leftcolumn">
<div id="leftnavigation">
<ul>
<li>Automoviles</li>
<li>Clases y Talleres</li>
<li>Electronicos</li>
<li>Inmobiliaria</li>
<li>Libros</li>
<li>Musica, Peliculas y Juegos</li>
<li>Ninos</li>
<li>Otros</li>
<li>Ropa</li>
</ul>
</div>
<div id="contactarea">
<p class="heading">Anuncios Premium</p>
<p class="tag">Destaque sus anuncios con una cuenta premium!</p>
</div>
</div>
<div id="contentarea">sdfg<h1>asdasd</h1></div>
<div id="advertisingarea">
<div class="advert">
<img src="../../Content/images/advertImage.png" alt="Advert" />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nibh nisi, volutpat a vehicula eget</p>
</div>
<div class="advert">
<img src="../../Content/images/advertImage.png" alt="Advert" />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nibh nisi, volutpat a vehicula eget</p>
</div>
<div class="advert">
<img src="../../Content/images/advertImage.png" alt="Advert" />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nibh nisi, volutpat a vehicula eget</p>
</div>
</div>
</div>
The easiest way is just to set the oveflow of the container:
#body
{
...
overflow: auto;
}
For a div to "wrap" around the elements it contains you have to float it (float:left) if you have already floated other elements.
For the floated div to be centered the best cross-browser solution is to wrap it on another not-floated div (invisible) and center that div. Something like this:
<div id="centered">
<div id="floated">
</div>
</div>
This way you can have the inside div wrapping the elements it contains while not specifying any hieght value, while the outer div (invisible, just with width) keeps it centered ;)
you should use firebug to resolve css issues like this. You'd be surprised how useful it is.
In answer to your question -
It has no height because of the floating elements. You need to clear the floats within that element for the parent to display as expected. You can do this a few ways.
make a clear class and simply add it as an element after the floats:
<style>
.clear{clear:both;}
</style>
<div class="parent">
<div class="float_left">left</div>
<div class="float_right">right</div>
<div class="clear"></div>
</div>
a more proper auto clear for any element that has a class of "container":
<style>
.container:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.container {
display: inline-block;
}
html[xmlns] .container {
display: block;
}
* html .container {
height: 1%;
}
</style>
<div class="parent container">
<div class="float_left">left</div>
<div class="float_right">right</div>
</div>