Correctly Aligning Images with HTML and CSS - html
I'm currently in the process of creating a HTML/CSS layout for a Kiosk-style site.
However, I am having a few issues making the alignment of the images and text to work exactly how I want.
The logo and header should be fixed in the same place across every page, whereas I might need to expand the amount of buttons on-screen.
Here is the illustration of an example: Example Image, where:
Black box represents logo
Blue boxes represent individual buttons
Current HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<link rel="stylesheet" type="text/css" href="style.css">
<html>
<body background="background.png">
<div id="logo">
<img src="logo.png">
</div>
<br>
<div id="icons1">
<img src="button-wmcweb.png"></a>
</div>
<div id="icons1">
<img src="button-appointments.png"></a>
</div>
<div id="icons1">
<img src="button-prescriptions.png"></a>
</div>
<br>
<div id="icons2">
<img src="button-somccg.png"></a>
</div>
<div id="icons2">
<img src="button-patient.png"></a>
</div>
<div id="icons2">
<img src="button-nhschoices.png"></a>
</div>
</body>
</html>
CSS:
body {
text-align:center;
}
#mainContainer {
margin:0 auto;
}
#icons1 {
display: inline-block;
}
#icons2 {
display: inline-block;
}
Is using inline blocks the best practice for what I'm trying to achieve?
Any help would be much appreciated.
I have created for you a JSFiddle with what you want as a starting point.
Click for the full screen mode for the fiddle.
There is the full code below for the ease of referencing.
index.html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body background="background.png">
<div id="logo">
<div id="logoimg">
<img src="http://cs614926.vk.me/v614926650/93b6/n9S5OGKt8L0.jpg" />
</div>
<div id="logotext">lorem ipsum</div>
</div>
<div class="row"> <a href="http://stackoverflow.com/">
<img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
</a> <a href="http://stackoverflow.com/">
<img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
</a> <a href="http://stackoverflow.com/">
<img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
</a>
</div>
<div class="row"> <a href="http://stackoverflow.com/">
<img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
</a> <a href="http://stackoverflow.com/">
<img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
</a> <a href="http://stackoverflow.com/">
<img src="http://cs614926.vk.me/v614926744/752f/eY60jo6aYo4.jpg" />
</a>
</div>
</body>
</html>
style.css:
body {
text-align: center;
}
#logoimg, #logotext, .row > img {
display: inline;
}
#logo, .row {
margin: 30px 10px;
min-width: 1000px;
}
#logotext {
min-width: 320px;
vertical-align: top;
font-size: 36px;
padding: 0 20px;
}
img {
width: 320px;
resize: noresize;
}
a:link {
text-decoration:none;
}
For more info on HTML/CSS, consider checking the following w3school tutorials: HTML and CSS.
Your HTML was wrong in a few places. No opening <a> tag, multiple id's with the same name, and the <link> for the css needs to be inside the <head></head> tags, as shown below.
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
Is this what you're looking to achieve?
http://jsfiddle.net/Q8gVL/
Related
HTML/CSS - Center Class Trouble
I can't get the .center class to apply to the following HTML. It gets applied to the ul element for some reason, but nothing else. Am I applying it wrong? Does it have something to do with IDs? I thought adding a class to a div would apply it to all elements within. .center { text-align: center; } ul { list-style: none; /* getting rid of bullet pts */ padding: 0; /* practice to remove padding so we can set it later */ } img { display: inline; width: 200px; /* we set in % or vh(view height) for responsive */ height: 100px; /* design - changes with page size (phones tablets etc) */ } #footer { width: 100%; border-top: solid 2px black; background-color: white; position: fixed; bottom: 0; } <!DOCTYPE html> <html lang="en"> <head> <title>Guessing Game</title> <link rel="stylesheet" type="text/css" href="style.css"> <!-- Bootstrap and CSS here--> </head> <body> <div id='app' class='center'> <div id='headers'> <!-- Title and subtitles! --> <h1 id='title' class='center'> Rav's Cheesy Guessing Game! </h1> <h2 id='subtitle'> Guess A Number Between 1-100, You Won't </h2> </div> <div id='main'> <div id='input-parent'> <!-- Player's guess input, and submit button --> <input id='player-input' class='center' placeholder="#" autofocus maxlength=2> <button id='submit-button' type=submit>Go!</button> </div> <div id='guesses'> <ul id='guess-list'> <li class='guess'>_</li> <li class='guess'>_</li> <li class='guess'>_</li> <li class='guess'>_</li> <li class='guess'>_</li> </ul> <!-- unordered list of guesses --> </div> <div id="menu-btns"> <!-- reset and hint buttons --> <button id='reset'>Reset</button> <button id='hint'>Hint</button> </div> </div> </div> <div id='footer' class='center'> <div> <div class=''> <img src='fa-logo#2x.png' alt="image"> </div> <div class=''> <h4>Project by Ravish Rawal</h4> </div> <div class=''> <img src='grace_hopper_academy.png' alt="image"> </div> </div> </div> </body> </html>
inline center three image
In my header I have three logos. I need to center those logoes, where there is a margin between them on around 100 - 140px. I did not know how to do that, so I solved it with putting a margin on 150px, with the result that the logos are not placed on mobile devices. On the mobile they should be vertical instead of horizontal. I actually thought I could do it like this: display: inline; margin: 0 auto; But that is not doing abything at all. Does anybody knows how I can solve this, so they also fit on mobile devices? <div class="fullscreen landing parallax"> <div class="overlay"> <div class="container"> <div class="row"> <div class="col-md-12 logo"> <!-- /.logo --> <img src="/img/seminar/company_1-logo-white-small.png" alt="company_1" class="logo"> <img src="/img/seminar/company_2-white.png" alt="company_2"> <img src="/img/seminar/company_3-white.png" alt="company_3"> </div> </div> </div> </div> </div> CSS .logo { margin: 20px 0 15px 0; } .logo img{ margin-left: 160px; width: 163px; }
Try to separate the row into 3 columns and place the images inside the column with bootstrap's text-center class. Bootstrap will align images vertically on mobile UI. On iPad horizotal On iPad vertical On desktop browser <!DOCTYPE html> <html> <head> <title>Page Title</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- Optional theme --> <style type="text/css"> .logo { margin: 20px 0 15px 0; } .logo img { margin-left: 160px; width: 163px; } </style> </head> <body> <div class="fullscreen landing parallax"> <div class="overlay"> <div class="container"> <div class="row"> <div class="col-md-4 text-center"> <img src="http://vignette4.wikia.nocookie.net/mrmen/images/5/52/Small.gif/revision/latest?cb=20100731114437" alt="company_1" class="logo"> </div> <div class="col-md-4 text-center"> <img src="http://vignette4.wikia.nocookie.net/mrmen/images/5/52/Small.gif/revision/latest?cb=20100731114437" alt="company_1" class="logo"> </div> <div class="col-md-4 text-center"> <img src="http://vignette4.wikia.nocookie.net/mrmen/images/5/52/Small.gif/revision/latest?cb=20100731114437" alt="company_1" class="logo"> </div> </div> </div> </div> </div> </body> </html>
Add this: .logo { display:flex; justify-content:center; align-items:center; } You'll probably need to set a width on the .logo element and maybe `margin:0 auto;' too depending on its width. For more info on flexbox: https://css-tricks.com/snippets/css/a-guide-to-flexbox/ Live example: .logo { display:flex; justify-content:center; align-items:center; } .logo img { margin-left:10px; margin-right:10px; } <div class="logo"> <img src="http://placekitten.com/200/100" alt=""> <img src="http://placekitten.com/200/100" alt=""> <img src="http://placekitten.com/200/100" alt=""> </div>
How do I prevent my H1 tag from moving out of sight (dissapearing)?
I haven't done much html and css lately and I can't figure out why my H1 disappears out of sight when I re-size the browser... <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script type="text/javascript src="Jquery1_10_2.js"> </script> <link rel="stylesheet" type="text/css" href="bootstrap.css" media="screen" /> <link rel="stylesheet" type="text/css" href="LogIn_Page.css" media="screen" /> <!-- <script type="text/javascript src="LogIn_Page.js"> </script> --> </head> <body> <div style="margin-top: 15px;text-align: center;" class="navbar navbar-inverse navbar-fixed-top container"> <img src="Logo.png" alt="somesite" style="width:225px; height:100px; text-align:center; margin-right:5px"> <img src="somesite_logo.png" alt="somesite" style="width:225px; height:100px; text-align:center;margin-right:5px; margin-left:5px;"> <img src="somesite.png" alt="somesite" style="width:225px; height:100px; text-align:center; margin-left:5px;"> </div> <div class="container body-content" style="margin-top: 125px;"> <div class="row"> <div class="col-md-12"> <H1 style="margin-bottom: 50px;">Welcome to the Crops web application</H1> <P>Please login:</P> <button onclick="window.location.href="/auth"" >Login link</button> </div> </div> </div> <div id="footer"> <footer> <script>window.onload = function() { var d = new Date(); var n = d.getFullYear(); document.getElementById("date").innerHTML = "© " + n + " My company";}</script> <p id="date"></p> </footer> </div> </body> </html> The three images stack on top of each other like they are supposed to, but its just the H1 tag that dispersal totally. I haven't even used any custom css, except for the default bootstrap package. Could someone point me out to the right solution? I tried putting inside the H1 tag the following styles: position, float, height, width, min-height, min-width, but none of those seem to work out for me it just keeps disappearing when I size down the browser to the max. Its there when the browser is full screen of course....
You can add position: relative to your navbar. .navbar.navbar-inverse { position: relative; } <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> <div style="margin-top: 15px;text-align: center;" class="navbar navbar-inverse navbar-fixed-top container"> <a href="http://somesite.com/" title="Web Site"> <img src="Logo.png" alt="somesite" style="width:225px; height:100px; text-align:center; margin-right:5px"> </a> <a href="http://www.somesite2.org/" title="Web Site"> <img src="somesite_logo.png" alt="somesite" style="width:225px; height:100px; text-align:center;margin-right:5px; margin-left:5px;"> </a> <a href="http://somesite3.com/" title="somesite Web Site"> <img src="somesite.png" alt="somesite" style="width:225px; height:100px; text-align:center; margin-left:5px;"> </a> </div> <div class="container body-content"> <div class="row"> <div class="col-md-12"> <h1 style="margin-bottom: 50px;">Welcome to the Crops web application</h1> <p>Please login:</p> <button onclick="window.location.href="/auth"">Login link</button> </div> </div> </div>
It's not disappearing, it just goes off the screen cause of it's huge size. Try using #media (max-width: _px) in CSS to change the position and text size of theh1` accordingly: #media (max-width:300px){ h1{ text-size: _px/em/%; <more styles here> } } So when the screen is less than 300px, it'll style the h1 to whatever you put in there.
It's not disappearing, it's just covered by the navbar. You need to add more margin for when the navbar elements stack up and expand the navbar. For example <div class="container body-content" style="margin-top: 300px;"> will make it appear. However you need to actually put it in a media query. With your fixed image widths those queries to add to the styles section would be #media (max-width: 732px) { .body-content { margin-top: 225px !important; } } #media (max-width: 499px) { .body-content { margin-top: 325px !important; } }
cannot make my data in small centerd gray boxes
This is the beginning of my html: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"></link> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"></link> <script type="script" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> </head> <body> <h1>Delta Fresh Samples:</h1> <p>save date: 08:23:11 31-May-02015</p> <div class="jumbotron" id="distance_small"> <h3>distance small</h3>0_1 <br> <a href="http://livemap-tiles1.waze.com/tiles/internal?lineGeom=(-71.1208,42.3317,-71.1052,42.3261,-71.0872,42.3354,-71.0570,42.3295,-71.0376,42.3394),(-71.1208,42.3317,-71.0754,42.3311,-71.0617,42.3428,-71.0376,42.3394),(-71.1208,42.3317,-71.0675,42.3525,-71.0376,42.3395)"> <img alt="missing livemap" src="http://livemap-tiles1.waze.com/tiles/internal?lineGeom=(-71.1208,42.3317,-71.1052,42.3261,-71.0872,42.3354,-71.0570,42.3295,-71.0376,42.3394),(-71.1208,42.3317,-71.0754,42.3311,-71.0617,42.3428,-71.0376,42.3394),(-71.1208,42.3317,-71.0675,42.3525,-71.0376,42.3395)" height="100" width="200"> </a> <br><span> </span>editor:<span><a title="0_0" href="https:/www.waze.com/editor/?lon=-71.1181994930557&lat=42.33211431130898&zoom=4&segments=66182276,22523498,22542379,69798169,70183731,70136684,22526478,77571254,77571249,83969671,83969602,83969601,83969300,83969562,83969306,83969308,83969311,83969444,22950508,22946295,63734947,63734946,22945044,76103782,61849159,22943314,22945842,22949040,76952893,22958740,22955108,22963930,22963937,61487751,78453835,78453836,78190323,78190322,22966401,22963938,22955881,22952772,22942713,22945900,61574081,22948993,22946660,61574071,67889632,67889631,67889637,22942168,22941119,22939556,22945627,61704033,63784515,69051844,61704023,22959771,78100291,78100305,78100306,75676668,22959690,22947454,22940596,22961456,22958490,22948978,22961457,22963582,65496487,22946251,22964699,74195770,75079286,22964701,22965880,62248964,78100492,78100491,22962630,22951570,22948096,22954294,66161229,66147839,22960015,22949762,22945545,22946824,22951606,22951605,22948122,22946840,22960419,22965961,22960420,22962680,22962685,22962684,22962683,22947641,22961812,22964726,22965877,22965967,22965964,22951601,22946847,22949797,75206339,75206338,22962702,22960433,22948128,22960544,22966245">alt 0</a></span><span><a title="0_1" href="https:/www.waze.com/editor/?lon=-71.1181994930557&lat=42.33211431130898&zoom=4&segments=66182276,22523498,22542379,69798169,70183731,70136684,22526478,77571254,77571249,83969671,83969602,83969601,83969300,83969562,83969306,83969308,83969311,83969776,83970667,83970668,83970679,83970678,83969787,83969884,83969791,83969889,83969965,62003149,22966553,22966554,22946589,22954701,22948771,22960706,22952457,22952456,69823920,67646833,22956976,22942713,22945900,61574081,22948993,22946660,61574071,67889632,67889631,67889637,22942168,22941119,22939556,22945627,61704033,63784515,69051844,61704067,61704043,22957408,61704040,72391451,72391452,61724192,61975137,61975144,57602828,61541078,22965716,22949679,22964912,22943804,22965887,22943805,81603700,81603658,22960396,22960397,22965904,22959154,22965764,22964822,22946555,22954865,22962698,22949797,75206339,75206338,22962702,22960433,22948128,22960544,22966245">alt 1</a></span><span><a title="0_2" href="https:/www.waze.com/editor/?lon=-71.1181994930557&lat=42.33211431130898&zoom=4&segments=66182276,22523498,22542379,69798169,70183731,70136684,22526478,22551059,22540619,22540617,22521289,22531355,22531357,22523497,77460394,77460392,61690687,67007203,67007202,22959509,22952362,22947304,22946552,73617242,77749675,73617397,22961888,22941066,62110860,83482398,83482876,83482875,22946605,74542235,83482565,83482564,61713972,74882174,74882173,69051742,61975892,65179805,65179806,61713939,77541139,77541140,61975883,22952799,61539504,57601394,22959961,22947692,22959735,22958946,22958947,22958607,22951490,22961077,22964301,22954627,22946241,22963491,76369581,22950499,22966864,22965699,22949657,22962492,22962497,22962496,22946416,22948460,22951483,22948007,22946064,22951140,61459698,22957970,22965738,22954249,22954934,22960321,78858435,22958543,69824727,69824726,22945987,22945859,67102730,77869444,77869443,22966245">alt 2</a></span> <br> </div> <div class="jumbotron" id="distance_large"> <h3>distance large</h3>0_0 <br> <a href="http://livemap-tiles1.waze.com/tiles/internal?lineGeom=(-71.1208,42.3317,-71.1052,42.3261,-71.0872,42.3354,-71.0570,42.3295,-71.0376,42.3394),(-71.1208,42.3317,-71.0754,42.3311,-71.0617,42.3428,-71.0376,42.3394),(-71.1208,42.3317,-71.0675,42.3525,-71.0376,42.3395)"> <img alt="missing livemap" src="http://livemap-tiles1.waze.com/tiles/internal?lineGeom=(-71.1208,42.3317,-71.1052,42.3261,-71.0872,42.3354,-71.0570,42.3295,-71.0376,42.3394),(-71.1208,42.3317,-71.0754,42.3311,-71.0617,42.3428,-71.0376,42.3394),(-71.1208,42.3317,-71.0675,42.3525,-71.0376,42.3395)" height="100" width="200"> </a> <br><span> </span>editor:<span><a title="0_0" href="https:/www.waze.com/editor/? and this is the result: I wanted to created boxes in the center of the page. I saw twitter bootstrap example (this example) but I cannot make class "jumbotron" center my data in medium size gray boxes. what am i missing? In Addition, if i would want to style this without twitter bootstrap how would you advise me to do this?
you can achieve that with some styling like this: html <h1>Delta Fresh Samples:</h1> <p>save date: 08:23:11 31-May-02015</p> <div class="jumbotron" id="distance_small"> <h3>distance small</h3>0_1 <br> <a href="http://livemap-tiles1.waze.com/tiles/internal?lineGeom=(-71.1208,42.3317,-71.1052,42.3261,-71.0872,42.3354,-71.0570,42.3295,-71.0376,42.3394),(-71.1208,42.3317,-71.0754,42.3311,-71.0617,42.3428,-71.0376,42.3394),(-71.1208,42.3317,-71.0675,42.3525,-71.0376,42.3395)"> <img alt="missing livemap" src="http://livemap-tiles1.waze.com/tiles/internal?lineGeom=(-71.1208,42.3317,-71.1052,42.3261,-71.0872,42.3354,-71.0570,42.3295,-71.0376,42.3394),(-71.1208,42.3317,-71.0754,42.3311,-71.0617,42.3428,-71.0376,42.3394),(-71.1208,42.3317,-71.0675,42.3525,-71.0376,42.3395)" height="100" width="200"> </a> <br><span>editor:</span><span><a title="0_0" href="https:/www.waze.com/editor/?lon=-71.1181994930557&lat=42.33211431130898&zoom=4&segments=66182276,22523498,22542379,69798169,70183731,70136684,22526478,77571254,77571249,83969671,83969602,83969601,83969300,83969562,83969306,83969308,83969311,83969444,22950508,22946295,63734947,63734946,22945044,76103782,61849159,22943314,22945842,22949040,76952893,22958740,22955108,22963930,22963937,61487751,78453835,78453836,78190323,78190322,22966401,22963938,22955881,22952772,22942713,22945900,61574081,22948993,22946660,61574071,67889632,67889631,67889637,22942168,22941119,22939556,22945627,61704033,63784515,69051844,61704023,22959771,78100291,78100305,78100306,75676668,22959690,22947454,22940596,22961456,22958490,22948978,22961457,22963582,65496487,22946251,22964699,74195770,75079286,22964701,22965880,62248964,78100492,78100491,22962630,22951570,22948096,22954294,66161229,66147839,22960015,22949762,22945545,22946824,22951606,22951605,22948122,22946840,22960419,22965961,22960420,22962680,22962685,22962684,22962683,22947641,22961812,22964726,22965877,22965967,22965964,22951601,22946847,22949797,75206339,75206338,22962702,22960433,22948128,22960544,22966245">alt 0</a></span><span><a title="0_1" href="https:/www.waze.com/editor/?lon=-71.1181994930557&lat=42.33211431130898&zoom=4&segments=66182276,22523498,22542379,69798169,70183731,70136684,22526478,77571254,77571249,83969671,83969602,83969601,83969300,83969562,83969306,83969308,83969311,83969776,83970667,83970668,83970679,83970678,83969787,83969884,83969791,83969889,83969965,62003149,22966553,22966554,22946589,22954701,22948771,22960706,22952457,22952456,69823920,67646833,22956976,22942713,22945900,61574081,22948993,22946660,61574071,67889632,67889631,67889637,22942168,22941119,22939556,22945627,61704033,63784515,69051844,61704067,61704043,22957408,61704040,72391451,72391452,61724192,61975137,61975144,57602828,61541078,22965716,22949679,22964912,22943804,22965887,22943805,81603700,81603658,22960396,22960397,22965904,22959154,22965764,22964822,22946555,22954865,22962698,22949797,75206339,75206338,22962702,22960433,22948128,22960544,22966245">alt 1</a></span><span><a title="0_2" href="https:/www.waze.com/editor/?lon=-71.1181994930557&lat=42.33211431130898&zoom=4&segments=66182276,22523498,22542379,69798169,70183731,70136684,22526478,22551059,22540619,22540617,22521289,22531355,22531357,22523497,77460394,77460392,61690687,67007203,67007202,22959509,22952362,22947304,22946552,73617242,77749675,73617397,22961888,22941066,62110860,83482398,83482876,83482875,22946605,74542235,83482565,83482564,61713972,74882174,74882173,69051742,61975892,65179805,65179806,61713939,77541139,77541140,61975883,22952799,61539504,57601394,22959961,22947692,22959735,22958946,22958947,22958607,22951490,22961077,22964301,22954627,22946241,22963491,76369581,22950499,22966864,22965699,22949657,22962492,22962497,22962496,22946416,22948460,22951483,22948007,22946064,22951140,61459698,22957970,22965738,22954249,22954934,22960321,78858435,22958543,69824727,69824726,22945987,22945859,67102730,77869444,77869443,22966245">alt 2</a></span> <br> </div> <div class="jumbotron" id="distance_large"> <h3>distance large</h3>0_0 <br> <a href="http://livemap-tiles1.waze.com/tiles/internal?lineGeom=(-71.1208,42.3317,-71.1052,42.3261,-71.0872,42.3354,-71.0570,42.3295,-71.0376,42.3394),(-71.1208,42.3317,-71.0754,42.3311,-71.0617,42.3428,-71.0376,42.3394),(-71.1208,42.3317,-71.0675,42.3525,-71.0376,42.3395)"> <img alt="missing livemap" src="http://livemap-tiles1.waze.com/tiles/internal?lineGeom=(-71.1208,42.3317,-71.1052,42.3261,-71.0872,42.3354,-71.0570,42.3295,-71.0376,42.3394),(-71.1208,42.3317,-71.0754,42.3311,-71.0617,42.3428,-71.0376,42.3394),(-71.1208,42.3317,-71.0675,42.3525,-71.0376,42.3395)" height="100" width="200"> </a> <br><span>editor:</span><span><a title="0_0" href="https:/www.waze.com/editor/?"></a> </div> css: .jumbotron{ background:#ddd; width:220px; margin:0 auto; } .jumbotron img{ display:block; margin:0 auto; } .jumbotron a,.jumbotron span{ display:inline-block; margin-left:10px; } see this fiddle
.jumbotron{ position : relative; margin: 0 auto; } and for being in one line use display: inline-block
Divs not auto resizing height inside another div
The solution has been found. The code is below. Thank you to everyone who helped. The Solution was to clear the float, the code below fixed it for me. .div#content:after { content:""; display:table; clear:both; } Thanks Again. Original Question I have 2 Divs, one being "Content" where all the content of my site is in. And another div named "updates". I want the div "content" to resize its height so that all the divs inside of it and fit. Here's an image explaining my problem easier Imgur Link, Not high enough rep to post image directly. Here's my full source code (html) (along with the css of content div and updates div. <html> <head> <link rel="stylesheet" type="text/css" href="css/reset.css"> <link rel="stylesheet" type="text/css" href="css/style.css"> <title>MCSocial</title> <script type="text/javascript" src="src/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="src/jquery.tinycircleslider.js"></script> </head> <body> <div id="container"> <div id="content"> <nav> <ul class="nav"> <li class="left">MCFish</li> <li>Home</li> <li>News</li> <li>Members</li> <li>Media</li> </ul> </nav> <a href="#"><div id="block"> <img src="img/mojang.jpg" height="200px" width="850px"> </div></a> <a href="#"><div id="block"> <img src="img/minecraft.jpg" height="200px" width="850px"> </div></a> <div id="updates"> <img src="img/update.png" height="48px" width="140px"> <!--post updates here--> <h3 class="sub-title">Update 1.5</h3> <p class="list">Added a new homepage! More simple to navigate! Enjoy!<br>Please send me some feedback here!</p> <h3 class="sub-title">Update 1.4</h3> <p class="list">Cleaned up code!</a></p> <h3 class="sub-title">Update 1.3</h3> <p class="list">Added new themes! Check them out!</a></p> <h3 class="sub-title">Update 1.2</h3> <p class="list">Renamed Site: from MinecraftFishing to MCFish!</a></p> <h3 class="sub-title">Update 1.0</h3> <p class="list">Site goes LIVE!</p> <!--end post updates--> </div> <div id="twitter"> <img src="img/twitter.png" height="48px" width="140px"><br><br> <a class="twitter-timeline" href="https://twitter.com/FluffyRabbitzZ" data-widget-id="544642022154723328">Tweets by #FluffyRabbitzZ</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> </div> <div id="footer"> <p>©2014. MCSocial. All Rights Reserved.</p> </div> </div> </div> </body> </html> and the CSS; div#content { width: 900px; margin-left: auto; margin-right: auto; background-color: #fff; height: auto; border-radius: 2px; min-height: 100%; position: relative; } div#updates { float: left; margin-left: 2.6%; } Thanks for any help.
You should clear the float. Add overflow CSS property (for example :auto) to the div#content. A solution for modern browsers : .div#content:after { content:""; display:table; clear:both; }
You have to clear the floating content: <div style="clear:both"></div> before closing yout div.content.