I am just trying to float these 3 divs to the left, so that they are all in one line. But whenever I apply float left to the id=abkitchen, it just does not float. I think it's because I've got a fixed header at the top of the page. Any idea how to do so that they float properly? Thanks in advance.
HTML:
<div id="headnav">
<ul>
<li>The Act</li>
<li>Kitchen Act</li>
<li>Social Act</li>
</ul>
</div>
<div id="logo"><img src="images/logo.png"></div>
<div id="filters">
<div class="section" id="utensils">
<ul>
<li>HANDS<input type="checkbox" name="hands" value=".hands" id="hands"><label for="hands"></label></li>
<li>FORK<input type="checkbox" name="fork" value=".fork" id="fork"><label for="fork"></label></li>
</ul>
</div>
<div class="section" id="food">
<ul>
<li><input type="checkbox" name="burger" value=".burger" id="burger"><label for="burger">BURGER</label></li>
<li><input type="checkbox" name="cupcake" value=".cupcake" id="cupcake"><label for="fork">CUPCAKE</label></li>
</ul>
</div>
</div>
<div id="abkitchen"><p><em>Kitchen Act</em> is an exploration presenting a series of videos that investigate the interaction people have with everyday utensils. By pairing everyday food with an unexpected utensil, for instance, a burger with chopsticks, these interactions aim to foster an appreciation towards these tools that are often considered secondary to food. By establishing that utensils are the bridge between us and our food, these videos assert that utensils play a defining role in our experience of a meal.</p></div>
CSS:
#headnav{
z-index:101;
position: absolute;
top: 0px;
height: 35px;
width: 100%;
background: #f9f9f9;
text-align: left;
font-size: 1em;
overflow: hidden;
padding: 0.35em 0.5%;
vertical-align: middle;
}
#headnav ul{
display:inline-block;
list-style-type:none;
margin:auto 0;
padding:8px;
}
#headnav li{
display:inline;
padding-right:10px;
margin-top:10px;
font-size: 14px;
}
#logo{
float:left;
padding:15px;
}
#abkitchen{
background-color: #E0E0E0;
padding:15px;
text-align: left;
width:50%;
}
#filters{
text-align: left;
padding:15px;
/*background-color: white;*/
}
#utensils, #food{
display: inline-block;
float:left;
width:auto;
height:auto;
background-color: yellow;
}
#utensils{
text-align: right;
padding-top: 15px;
padding-left: 15px;
padding-bottom: 15px;
}
#food{
padding-top: 15px;
padding-right: 15px;
padding-bottom: 15px;
margin-left: -5px;
}
li{
list-style-type: none;
}
First of all - you have a typo in #utensils, #food{, you need float:left;
Second of all, you need to set float property to ALL elements that you need to float.
Start simple, and make three divs that float, and work from there.
Next problems that you will encounter would be - your divs move down. You need to set the width for all of them, and then encapsulate them all in a bigger div. And after all of the floating divs, I personally put one empty div that just has clear: both; in it.
Observe:
<div style="width: 381px; border: 1px solid #000000;">
<div style="float: left; width: 125px; border: 1px solid #FF0000;">
I am RED!!!
</div>
<div style="float: left; width: 125px; border: 1px solid #00CC00;">
I am Green!!!
</div>
<div style="float: left; width: 125px; border: 1px solid #0000FF;">
I am Blue!!!
</div>
<div style="clear: both;"></div>
</div>
<div style="border: 1px solid #000000;">And my behaviour is completely unacceptable!</div>
This way you make sure the elements stay in place no matter how much you resize the window...
I think you should just add "clearfix".
Here's the HTML:
<div id="logo"><img src="images/logo.png"></div>
<div id="filters">
<div class="section" id="utensils">
<ul>
<li>HANDS<input type="checkbox" name="hands" value=".hands" id="hands"><label for="hands"></label></li>
<li>FORK<input type="checkbox" name="fork" value=".fork" id="fork"><label for="fork"></label></li>
</ul>
</div>
<div class="section" id="food">
<ul>
<li><input type="checkbox" name="burger" value=".burger" id="burger"><label for="burger">BURGER</label></li>
<li><input type="checkbox" name="cupcake" value=".cupcake" id="cupcake"><label for="fork">CUPCAKE</label></li>
</ul>
</div>
</div>
<div id="abkitchen"><p><em>Kitchen Act</em> is an exploration presenting a series of videos that investigate the interaction people have with everyday utensils. By pairing everyday food with an unexpected utensil, for instance, a burger with chopsticks, these interactions aim to foster an appreciation towards these tools that are often considered secondary to food. By establishing that utensils are the bridge between us and our food, these videos assert that utensils play a defining role in our experience of a meal.</p></div>
<div class="clearfix"></div>
And the CSS code:
#logo{
float:left;
padding:15px;
}
#abkitchen{
background-color: #E0E0E0;
padding:15px;
text-align: left;
width:50%;
}
#filters{
text-align: left;
padding:15px;
/*background-color: white;*/
}
#utensils, #food{
display: inline-block;
float;left;
width:auto;
height:auto;
background-color: yellow;
}
#utensils{
text-align: right;
padding-top: 15px;
padding-left: 15px;
padding-bottom: 15px;
}
#food{
padding-top: 15px;
padding-right: 15px;
padding-bottom: 15px;
margin-left: -5px;
}
li{
list-style-type: none;
}
.clearfix{
clear: both;
}
I hope it works fine.
Try to be more specific when you say "three divs"...
Anyway, i suggest you start by adding your divs with minimum content and some basic CSS. When this works, start adding content and more CSS.
HTML
<div id="logo">
<p>this is logo</p>
</div>
<div id="filters">
<p>this is filters</p>
</div>
<div id="abkitchen">
<p>this is abkitchen</p>
</div>
CSS:
#logo,
#filters,
#abkitchen {
float: left;
padding: 20px;
border: 1px solid #eee;
}
Related
I've been trying to add two div containers into another one. One floating on the left and the other one on to the right side of the main container. The problem is, if I add float:left on the first div, it's no longer contained in the main container.
Before adding float: https://imgur.com/a/OACA7Su
After adding it: https://imgur.com/a/ukeZoae
HTML:
<div class="container">
<div class="column1">
<div class="rowTop">
<p>Community</p>
</div>
<div class="row">
<div id="leftSide">
<h3><a>Disscusion</a></h3>
<p>→ Disscusions about various games like Warframe or HuntShowdown</p>
</div>
<div id="rightSide">
0:Threds
</div>
</div>
<div class="row">
</div>
<div class="row">
</div>
</div>
<div class="column2">
</div>
</div>
CSS:
.container{
margin:30px;
}
.column1{
width:70%;
float:left;
}
.column2{
width:15%;
float:right;
padding:2px;
}
.rowTop{
background-color: rgb(0, 51, 0);
border:1px solid white;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
width:10%;
text-align: center;
text-shadow: black 1px 1px;
color:white;
}
.row{
background-color: black;
border:1px solid white;
color:white;
display: block;
padding:0;
}
.row #leftSide{
color:white;
float: left;
margin-right: 0;
width: 55%;
}
Thanks in advance for the help.
Please don't give me any hate, I'm new to coding :3
You can use Flexbox for this. Check out the guide for your CSS. Just change the display to flex:
.row{
background-color: black;
border:1px solid white;
color:white;
display: flex;
flex-direction: row
padding:0;
}
I am having trouble getting my image to be on the right side of the information that I am trying to display. My CSS skills are lacking and becoming more and more apparent, so the help is very appreciated.
Here is my HTML
<div id="facility_general_info">
<div id="facility_info">
<h3>Facility Information</h3>
<div id="facility_data">
<ul>
<li><b>Facility Number</b><p>...</p></li>
<li><b>Facility Name</b><p>...</p></li>
<li><b>Address</b><p>...</p></li>
<li><b>City</b><p>...</p></li>
<li><b>Province</b><p>...</p></li>
<li><b>Postal Code</b><p>...</p></li>
<li><b>Roof Area</b><p>...</p></li>
<li><b>Roof Area Inspected</b><p>...</p></li>
<li><b>Last Inspected</b><p>...</p></li>
<li><b>Inspected By</b><p>...</p></li>
<ul>
</div>
<!--facility front image-->
<div id="facility_image">
<div id="fac_image_wrapper">
<img src="http://i.imgur.com/rQ5G8sZ.jpg?2" width="250"/>
</div>
<br />
</div>
</div>
</div>
I am trying to get #facility_image to "float" to the right side of #facility_data.
Here is my CSS
#facility_general_info {
padding: 5px;
float: left;
width: 750px;
line-height: 110%;
}
#facility_info ul {
margin-left: -40px;
list-style-type: none;
}
#facility_info h3 {
color: #0d55b7;
border-bottom: 2px solid #0d55b7;
}
#facility_info {
margin-left: 50px;
width: 750px;
float:left;
}
#facility_data{
width: 375px;
margin: 0 !important;
}
/*facility image*/
#facility_image {
margin-top: 100px;
margin-left: 400px;
width: 350px;
padding: 5px;
float: left;
}
#fac_image_wrapper p {
width: 250px;
}
#fac_image_wrapper{
text-align: center;
}
Here is a JSfiddle.
How can I float my image to the right hand side of the data I am trying to display?
You are setting a huge margin to the image div that is putting it way down the screen.
Let the #facility_data take 60% of the container div and float left, and let the image take the other 37% and remove the margin. You also need to give some margin right for #facility_data to keep some space between the 2 divisions :
#facility_image {
/*margin-top: 100px; <<<<< huge margin
margin-left: 400px;<<<<< huge margin*/
width: 37%;
padding: 5px;
float: left;
}
#facility_data
{
width:60%;
margin-right:2%;
float:left;
}
Working example :
#facility_general_info {
padding: 5px;
float: left;
width: 750px;
line-height: 110%;
}
#facility_info ul {
margin-left: -40px;
list-style-type: none;
}
#facility_info h3 {
color: #0d55b7;
border-bottom: 2px solid #0d55b7;
}
#facility_info {
margin-left: 50px;
width: 750px;
float:left;
}
#facility_data{
width: 375px;
margin: 0 !important;
}
/*facility image*/
#facility_image {
width: 37%;
padding: 5px;
float: left;
}
#facility_data
{
width:60%;
margin-right:2%;
float:left;
}
#fac_image_wrapper p {
width: 250px;
}
#fac_image_wrapper{
text-align: center;
}
<div id="facility_general_info">
<div id="facility_info">
<h3>Facility Information</h3>
<div id="facility_data">
<ul>
<li><b>Facility Number</b><p>...</p></li>
<li><b>Facility Name</b><p>...</p></li>
<li><b>Address</b><p>...</p></li>
<li><b>City</b><p>...</p></li>
<li><b>Province</b><p>...</p></li>
<li><b>Postal Code</b><p>...</p></li>
<li><b>Roof Area</b><p>...</p></li>
<li><b>Roof Area Inspected</b><p>...</p></li>
<li><b>Last Inspected</b><p>...</p></li>
<li><b>Inspected By</b><p>...</p></li>
<ul>
</div>
<!--facility front image-->
<div id="facility_image">
<div id="fac_image_wrapper">
<img src="http://i.imgur.com/rQ5G8sZ.jpg?2" width="250"/>
</div>
<br />
</div>
</div>
</div>
Use display: inline-block to place the image horizontally with the data. Remove the margin set for the image since the image is already inside the parent container. Give a float: left for both the elements as the data comes first in the DOM, the image will go to the right.
#facility_general_info {
padding: 5px;
float: left;
width: 750px;
line-height: 110%;
}
#facility_info ul {
margin-left: -40px;
list-style-type: none;
}
#facility_info h3 {
color: #0d55b7;
border-bottom: 2px solid #0d55b7;
}
#facility_info {
margin-left: 50px;
width: 750px;
float: left; /* Add */
}
#facility_data {
width: 375px;
margin: 0 !important;
display: inline-block; /* Add */
float: left; /* Add */
}
/*facility image*/
#facility_image {
width: 350px;
padding: 5px;
float: left;
}
#fac_image_wrapper p {
width: 250px;
}
#fac_image_wrapper {
text-align: center;
}
<div id="facility_general_info">
<div id="facility_info">
<h3>Facility Information</h3>
<div id="facility_data">
<ul>
<li><b>Facility Number</b>
<p>...</p>
</li>
<li><b>Facility Name</b>
<p>...</p>
</li>
<li><b>Address</b>
<p>...</p>
</li>
<li><b>City</b>
<p>...</p>
</li>
<li><b>Province</b>
<p>...</p>
</li>
<li><b>Postal Code</b>
<p>...</p>
</li>
<li><b>Roof Area</b>
<p>...</p>
</li>
<li><b>Roof Area Inspected</b>
<p>...</p>
</li>
<li><b>Last Inspected</b>
<p>...</p>
</li>
<li><b>Inspected By</b>
<p>...</p>
</li>
<ul>
</div>
<!--facility front image-->
<div id="facility_image">
<div id="fac_image_wrapper">
<img src="http://i.imgur.com/rQ5G8sZ.jpg?2" width="250" />
</div>
<br />
</div>
</div>
</div>
you have lacked float
#facility_data {
float: left;
}
#facility_image {
margin-top: 0;
margin-left: 0;
}
although not the best technique, you can learn to use FlexBox https://css-tricks.com/snippets/css/a-guide-to-flexbox/
I've tidied up your JSFiddle, removing some of the unecessary HTML elements and also fixing an error in the HTML, which was the second <ul>. It should have been </ul>to close the list.
In the jsfiddle, we can see the following reduced css as an example:
.facility_info {
width: 800px;
}
.facility-list {
float:left;
width: 400px;
}
.facility-image {
width: 350px;
float: right;
}
.facility_info is wide enough to accomodate both the defined child widths and also the browser default <ul> styling which adds a margin.
Then the two children are floated left and right respectively. The selectors are added directly to the <ul> and <img /> tags as you don't need wrappers (though you could wrap these children and apply the css to the wrapper).
I've used classes rather than ids, this is better in the long run as it makes it easier to maintain css on a project. IDs add styles in a way that is hard to over-ride, can't be re-used and are unnecessary for styling.
Apart from this, you were also suffering a bit from the default css properties added to html elements by browsers. Loading a reset.css file will help with this. A reset css declaration loads some defaults at the top of the css file that set various values to 0 to over-ride the default properties set by the browser. It gives you a more consistent and less confusing base to start styling from
I have a footer on page and then I want to place a few divs above it but for some reason the footer seems to come up beside this divs instead of below it
I want the main footer to be above the footer
here is my code
<div id ="mainfooter">
<div id = "links">
<h2>Quick Links</h2>
</div>
<div id ="sunday">
<h2>Join us this Sunday</h2>
<p>11am & 6:30pm</p>
</div>
<div id="findus">
<h2>Find Us</h2>
</div>
</div>
<div id="footer">
<p id="copyright"> © <span id="copyright_span"></span> Elim Church</p>
</div>
here is my css
#links
{
padding-left: 20px;
color: #000;
width: 150px;
float: left;
}
#sunday{
padding-left: 100px;
width: 200px;
color: #000;
float: left;
}
#findus{
padding-left: 100px;
color: #000;
width: 200px;
float: left;
}
#mainfooter
{
padding-top: 50px;
}
#footer {
padding-top: 50px;
padding-left:100px;
background:#F3EFE0;
padding-bottom:40px;
}
You have to clear after floated elements, add clear: both to #footer.
#footer {clear: both;}
https://jsfiddle.net/u0krtdjo/
I have a website and I am adding a footer to all the pages. On all the pages except for one with boxes on the right side of the page, the footer stays on the bottom. On that page, the footer appears floated to the left of the text, not at the bottom where it should be. Here is the code for that particular page:
HTML
<aside class="expert">
<h2>Always a Satisfied Customer</h2>
<ul class="b">
<li>Upfront Pricing</li>
<li>Affordable Rates</li>
<li>Courteous and Respectful</li>
<li>Always On Time</li>
</ul>
</aside>
<aside class="refer">
<p>I would recommend EJP to anyone and everyone! They showed up, looked at my issue, and fixed it promptly. They are simply the best! <br />-Tim S.</p>
</aside>
<p>EJP Electric offers repairs, upgrades, and installations, delivering high customer satisfaction by getting the job done right the first time.</p>
<footer>
<div id="footer">
<address>EJP Electric<br />
8603 E M115<br />
Cadillac, MI 49601<br />
231-775-3799<br />
Email
</address>
</div>
</footer>
CSS
.expert {
background-color: white;
display: block;
border: solid;
float: right;
right: 20px;
padding: 3px;
}
.refer {
background-color: white;
border: solid;
float: right;
clear: right;
width: 150px;
display: block;
margin-top: 5px;
padding: 5px;
}
#footer {
position: absolute;
width: 600px;
font-size: 12px;
float: left;
}
You should clear the floating with the clear property:
The clear CSS property specifies whether an element can be next to
floating elements that precede it or must be moved down (cleared)
below them.
footer {
clear: both;
}
.expert {
background-color: white;
display: block;
border: solid;
float: right;
right: 20px;
padding: 3px;
}
.refer {
background-color: white;
border: solid;
float: right;
clear: right;
width: 150px;
display: block;
margin-top: 5px;
padding: 5px;
}
#footer {
position: absolute;
width: 600px;
font-size: 12px;
float: left;
}
footer {
clear: both;
}
<aside class="expert">
<h2>Always a Satisfied Customer</h2>
<ul class="b">
<li>Upfront Pricing</li>
<li>Affordable Rates</li>
<li>Courteous and Respectful</li>
<li>Always On Time</li>
</ul>
</aside>
<aside class="refer">
<p>I would recommend EJP to anyone and everyone! They showed up, looked at my issue, and fixed it promptly. They are simply the best! <br />-Tim S.</p>
</aside>
<p>EJP Electric offers repairs, upgrades, and installations, delivering high customer satisfaction by getting the job done right the first time.</p>
<footer>
<div id="footer">
<address>EJP Electric<br />
8603 E M115<br />
Cadillac, MI 49601<br />
231-775-3799<br />
Email</address>
</div>
</footer>
Your markup is not correct according to HTML5 semantic, of course if its not only the part of it, you can read about this here: html5doctor
Now about your question:
html, body, #wrap { height: 100%; }
body > #wrap {height: auto; min-height: 100%;}
#main {
padding-bottom: 150px; /*should be the same as footer height*/
}
#footer {
position: relative;
margin-top: -150px; /*negative value of footer height*/
height: 150px;
clear: both;
}
<div id="wrap">
<div id="main"></div>
</div>
<div id="footer"></div>
I am trying to align multiple divs (buttonNav) to the bottom of a container div (lowerNav). I have read every question on here regarding this and tried the CSS and it does not seem to work. I tried this one: Stacking Divs from Bottom to Top amoung others, hoping someone can help.
Here is my html, I have 5 of the lowerNav containers each with multiple buttonNavs that I want to align to the bottom of the lowerNav here is the code from one, they are all set up the same way:
<div class="lowerNav">
<img src="image/contact-us.gif" width="126" height="27" alt=""/>
<p>Ready to get more information or contact us directly?</p>
<div class="buttonNav">
<p>Order Literature</p>
</div>
<div class="buttonNav">
<p>Downloads</p>
</div>
<div class="buttonNav">
<p>Email Sign-Up</p>
</div>
<div class="buttonNav">
<p>Meet Your Rep</p>
</div>
<div class="buttonNav">
<p>Ask a Question</p>
</div>
</div>
Here is my CSS:
.lowerNav {
width: 160px;
height: 325px;
background-color: #e3dfd7;
border: 3px solid #383431;
float: left;
margin: 15px 8px 0px 8px;
text-align: left;
display: table-cell;
vertical-align: bottom;
}
.lowerNav p {
padding: 5px 12px 12px 12px;
}
.lowerNav img {
padding-top: 12px;
}
.buttonNav {
background:url(image/button-lowerNav.jpg);
width: 160px;
height: 45px;
display: inline-block;
}
.buttonNav p {
text-align:center;
padding-top: 14px;
}
.buttonNav a {
color: #fff;
font-size: 13px;
text-decoration:none;
font-weight:700;
}
.buttonNav a:hover {
color: #fff;
font-size: 13px;
text-decoration:underline;
font-weight:700;
}
Since the container (.lowerNav) has a fixed height and you know the size of its content this is quite easy to do with absolute positioning.
HTML:
<div class="outer">
Hello up here!
<ul class="inner">
<li>Hello</li>
<li>down</li>
<li>there!</li>
</ul>
</div>
CSS:
.outer {
position: relative;
height: 200px;
}
.inner {
position: absolute;
bottom: 0;
}
Check this CodePen for a live example of this code: http://codepen.io/EvilOatmeal/pen/fCzIv