Very new to CSS, so apologies if this is simple beyond belief.
I am currently working on a page for class. There is a section where icons (coffee, music notes, food and a waiter) need to be floated above their respective headings. I have tried floating and clearing various elements. I hope I am just overlooking something simple!
I cannot edit the HTML in any way or I will receive a zero on the assignment, and I am only allowed to use CSS.
I am having trouble posting the code, so I hope it is okay to share the links.
HTML
https://github.com/melonysmith/dws1/blob/gh-pages/DWS1-Practical/index.html
CSS
https://github.com/melonysmith/dws1/blob/gh-pages/DWS1-Practical/css/styles.css
Any and all help and suggestions are welcome and very much appreciated!
EDIT: HTML and CSS posted.
I did get the icons to center above their headings, but I cannot seem to figure out how to get the "promo" section to center to the rest of the page, including the icons, headers and paragraphs.
<!-- begin promo -->
<section id="promo">
<div id="promo-first-col" class="promo-col">
<h3 id="coffee">Imported Coffee</h3>
<p>Checkout our various tyes of imported coffee.</p>
</div>
<div class="promo-col">
<h3 id="music">Great Music</h3>
<p>Our DJs will entertain you like never before.</p>
</div>
<div class="promo-col">
<h3 id="food">Finest Cuisine</h3>
<p>From Italian to Tex-Mex, you will find all types of food</p>
</div>
<div class="promo-col">
<h3 id="service">Nice Staff</h3>
<p>You will never forget our smile and professional attitude. </p>
</div>
</section>
<!-- end promo -->
#promo {
display: inline-block;
width: 100%;
background-color: #fff;
display: inline-block;
padding-bottom: 50px;
margin: 0 auto;
}
#promo p {
background-color: #fff;
width: 255px;
text-align: center;
margin: 0 auto;
}
#promo h3 {
background-color: #fff;
width: 255px;
text-align: center;
padding-top: 80px;
margin: 0 0 50px 0;
}
.promo-first-col {
display: inline-block;
background-color: #fff;
text-align: center;
width: 255px;
margin: 0 auto;
padding-top: 20px;
}
.promo-col {
display: inline-block;
background-color: #fff;
text-align: center;
width: 255px;
margin:0 auto;
padding-top: 20px;
}
#coffee {
float: left;
width: 255px;
background: #fff;
background-image: url("../images/ico_coffee.png");
background-position: center top;
line-height: 25px;
background-repeat: no-repeat;
text-align: center;
padding-top: 10px;
padding-right: 30px;
float: left;
}
#music {
float: left;
width: 255px;
background: #fff;
line-height: 25px;
background-image: url("../images/ico_music.png");
background-position: center top;
background-repeat: no-repeat;
text-align: center;
padding-top: 10px;
padding-right: 30px;
float: left;
}
#food {
float: left;
width: 255px;
background: #fff;
line-height: 25px;
background-image: url("../images/ico_food.png");
background-position: center top;
background-repeat: no-repeat;
text-align: center;
padding-right: 30px;
float: left;
}
#service {
float: left;
width: 255px;
background: #fff;
line-height: 25px;
background-image: url("../images/ico_service.png");
background-position: center top;
background-repeat: no-repeat;
text-align: center;
padding-top: 10px;
padding-right: 30px;
float: left;
clear: both;
}
.clear {
clear: both;
}
EDIT 2: Going to try and attempt to post a snippet. I'm new here, forgive my awkwardness!
All of the images, headers and paragraphs should be next to each other in a line with the image above the heading and the heading above the paragraph. That part I have figured out. Might need more code to explain, but this entire "promo" div is sitting to the left of the rest of the page, which is centered.
#promo {
display: inline-block;
width: 100%;
background-color: #fff;
display: inline-block;
padding-bottom: 50px;
margin: 0 auto;
}
#promo p {
background-color: #fff;
width: 255px;
text-align: center;
margin: 0 auto;
}
#promo h3 {
background-color: #fff;
width: 255px;
text-align: center;
padding-top: 80px;
margin: 0 0 50px 0;
}
.promo-first-col {
display: inline-block;
background-color: #fff;
text-align: center;
width: 255px;
margin: 0 auto;
padding-top: 20px;
}
.promo-col {
display: inline-block;
background-color: #fff;
text-align: center;
width: 255px;
margin:0 auto;
padding-top: 20px;
}
#coffee {
float: left;
width: 255px;
background: #fff;
background-image: url("http://melonysmith.github.io/dws/DWS1-Practical/images/ico_coffee.png");
background-position: center top;
line-height: 25px;
background-repeat: no-repeat;
text-align: center;
padding-top: 10px;
padding-right: 30px;
float: left;
}
#music {
float: left;
width: 255px;
background: #fff;
line-height: 25px;
background-image: url("http://melonysmith.github.io/dws/DWS1-Practical/images/ico_music.png");
background-position: center top;
background-repeat: no-repeat;
text-align: center;
padding-top: 10px;
padding-right: 30px;
float: left;
}
#food {
float: left;
width: 255px;
background: #fff;
line-height: 25px;
background-image: url("http://melonysmith.github.io/dws/DWS1-Practical/images/ico_food.png");
background-position: center top;
background-repeat: no-repeat;
text-align: center;
padding-right: 30px;
float: left;
}
#service {
float: left;
width: 255px;
background: #fff;
line-height: 25px;
background-image: url("http://melonysmith.github.io/dws/DWS1-Practical/images/ico_service.png");
background-position: center top;
background-repeat: no-repeat;
text-align: center;
padding-top: 10px;
padding-right: 30px;
float: left;
clear: both;
}
.clear {
clear: both;
}
<!-- begin promo -->
<section id="promo">
<div id="promo-first-col" class="promo-col">
<h3 id="coffee">Imported Coffee</h3>
<p>Checkout our various tyes of imported coffee.</p>
</div>
<div class="promo-col">
<h3 id="music">Great Music</h3>
<p>Our DJs will entertain you like never before.</p>
</div>
<div class="promo-col">
<h3 id="food">Finest Cuisine</h3>
<p>From Italian to Tex-Mex, you will find all types of food</p>
</div>
<div class="promo-col">
<h3 id="service">Nice Staff</h3>
<p>You will never forget our smile and professional attitude.</p>
</div>
</section>
<!-- end promo -->
Create two container divs: one containing the coffee div and the cuisine div, and the other containing the other two divs. Set the container on the left to
float: left;
and the other to
float: right;
There are now several ways you can go about this. One way would be to set both containers a
width: 50%
and for the contained two divs in each column/container
text-align: center;
OR
You could simply give them the float properties and then set margin-left on the left one and margin-right on the right one, and play around with the margins a bit until you get them where you want them.
Hope that helps!
Related
I've seen this asked on SO but I can't seem to get it to work. I am trying to take a horizontal ul and have it change to vertical when the screen size is less than 768px.
Here is my css code:
/* HeaderWrap */
#headerwrap {
background: url(../img/topgraph.png) no-repeat center top;
position: relative;
background-color: #3e86c3;
background-size: cover;
margin-top: -20px;
padding-top: 200px;
height:100vh;
background-attachment: scroll;
background-position: 0px 0px;
background-repeat: no-repeat;
min-height: 650px;
width: 100%;
-webkit-background-size: 100%;
-moz-background-size: 100%;
-o-background-size: 100%;
background-size: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#headerwrap h1 {
text-align: center;
margin-top: 60px;
margin-bottom: 15px;
color: white;
font-size: 45px;
font-weight: 300;
letter-spacing: 1px;
}
#headerwrap h2 {
text-align: center;
margin: 60px 200px 15px 200px;
color: white;
font-size: 35px;
font-weight: 300;
letter-spacing: 1px;
}
#headerwrap .header-links {
position: absolute;
bottom: 0;
text-align: center;
width: 100%;
height: 160px;
color: #fff;
padding-bottom: 20px;
}
#headerwrap ul {
text-align: center;
text-decoration: none;
list-style-type: none;
margin: 0;
overflow: hidden;
}
#headerwrap li {
float: left;
padding-left: 18%;
font-size: 24px;
}
#headerwrap img {
width: 100px;
height: 100px;
}
#media (max-width: 768px) {
#headerwrap {
padding-top: 100px;
}
#headerwrap h1 {
margin-top: 60px;
font-size: 36px;
}
#headerwrap h2 {
margin: 30px 50px 15px 50px;
font-size: 20px;
}
#headerwrap .header-links {
position: absolute;
bottom: 0;
text-align: center;
width: 100%;
height: 340px;
color: #fff;
padding-bottom: 20px;
}
#headerwrap li {
font-size: 18px;
display: block !important;;
padding: 0;
}
#headerwrap img {
width: 60px;
height: 60px;
}
<div id="headerwrap">
<div class="row">
<h1>Headline</h1>
<h2>Marketing blurb </h2>
<div class="col-lg-6">
</div>
<div>
<!--<img src="img/topgraph.png" class="bg">-->
</div>
</div>
<div class="header-links">
<ul>
<li><img src="img/icons/icnDevelopers_wh.png"><br>Prebid.JS</li>
<li><img src="img/icons/icnGetStarted_wh.png"><br>Get Started!</li>
<li><img src="img/icons/icnAdOps_wh.png"><br>Ad Ops</li>
</ul>
</div>
</div>
<!-- /headerwrap -->
No matter what I do within the #media query the li elements stay horizontal. Any help would be appreciated.
On your #media you have to set the width property of your ul and li to the 100%
#media (max-width: 768px) {
...
#headerwrap ul {
float: left;
width: 100%;
}
#headerwrap li {
width: 100%;
}
...
}
Very simple example using flexbox.
https://codepen.io/anon/pen/QZEXVg
Key is the media query enforcing the constraint.
#media (min-width: 768px) {
.navbar__list {
display: flex;
justify-content: flex-start;
}
}
Add width: 100% to the <li> in the #media query.
Demo:
/* HeaderWrap */
#headerwrap {
background: url(../img/topgraph.png) no-repeat center top;
position: relative;
background-color: #3e86c3;
background-size: cover;
margin-top: -20px;
padding-top: 200px;
height:100vh;
background-attachment: scroll;
background-position: 0px 0px;
background-repeat: no-repeat;
min-height: 650px;
width: 100%;
-webkit-background-size: 100%;
-moz-background-size: 100%;
-o-background-size: 100%;
background-size: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#headerwrap h1 {
text-align: center;
margin-top: 60px;
margin-bottom: 15px;
color: white;
font-size: 45px;
font-weight: 300;
letter-spacing: 1px;
}
#headerwrap h2 {
text-align: center;
margin: 60px 200px 15px 200px;
color: white;
font-size: 35px;
font-weight: 300;
letter-spacing: 1px;
}
#headerwrap .header-links {
position: absolute;
bottom: 0;
text-align: center;
width: 100%;
height: 160px;
color: #fff;
padding-bottom: 20px;
}
#headerwrap ul {
text-align: center;
text-decoration: none;
list-style-type: none;
margin: 0;
overflow: hidden;
}
#headerwrap li {
float: left;
padding-left: 18%;
font-size: 24px;
}
#headerwrap img {
width: 100px;
height: 100px;
}
#media (max-width: 768px) {
#headerwrap {
padding-top: 100px;
}
#headerwrap h1 {
margin-top: 60px;
font-size: 36px;
}
#headerwrap h2 {
margin: 30px 50px 15px 50px;
font-size: 20px;
}
#headerwrap .header-links {
position: absolute;
bottom: 0;
text-align: center;
width: 100%;
height: 340px;
color: #fff;
padding-bottom: 20px;
}
#headerwrap li {
font-size: 18px;
display: block !important;
padding: 0;
width: 100%
}
#headerwrap img {
width: 60px;
height: 60px;
}
<div id="headerwrap">
<div class="row">
<h1>Headline</h1>
<h2>Marketing blurb </h2>
<div class="col-lg-6">
</div>
<div>
<!--<img src="img/topgraph.png" class="bg">-->
</div>
</div>
<div class="header-links">
<ul>
<li><img src="img/icons/icnDevelopers_wh.png"><br>Prebid.JS</li>
<li><img src="img/icons/icnGetStarted_wh.png"><br>Get Started!</li>
<li><img src="img/icons/icnAdOps_wh.png"><br>Ad Ops</li>
</ul>
</div>
</div>
<!-- /headerwrap -->
Remove float: left; for the "regular" li elements and add display: inline-block instead. Otherwise they will also be floated (displayed next to each other) on smaller screens.
Or add float: none in the media query.
I'm struggling with a CSS issue and I was hoping for some help.
Here's the story:
I'm designing a header. It's split in two divs. First one must be 70% wide and second one 30% wide. I used the css-property "Display: table-cell" in order to place them side by side.
div.chapo {
width: 70%;
display: table-cell;
}
div.img_header {
width: 30%;
display: table-cell;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
-webkit-background-size: cover;
background-image: url(...);
}
It's working fine when the text placed in the first div is long enough:
Buuuut... when text is short, it's all messy:
I can't figure out why my widths values aren't kept in this specific case.
Thanks in advance for all who would be kind enough to help me...
Here's the fiddle link: https://jsfiddle.net/vinny38/verucw8p/3/
I wrapped both div ce_text chapo and img_header to .test-wrap class and give it to below css:
.test-wrap {
display: table;
width: 100%;
}
body,
div {
margin: 0;
padding: 0;
font-family: 'Roboto condensed', sans-serif;
}
div.inside {
position: relative;
}
div.chapo {
background-color: #ef4056;
background-image: none;
width: 70%;
height: 255px;
display: table-cell;
vertical-align: top;
background-color: #aaa;
color: #fff;
padding: 20px 8%;
position: relative;
}
h1 {
margin-top: 0;
font: 1.4em 'Oswald', Helvetica, sans-serif;
font-weight: bold;
text-transform: uppercase;
}
div.chapo p {
width: 100%;
min-width: 100%;
position: relative;
padding: 0;
font-size: 1em;
font-weight: 300;
}
div.img_header {
width: 30%;
position: relative;
display: table-cell;
vertical-align: top;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
-webkit-background-size: cover;
background-image: url(https://image.freepik.com/free-psd/abstract-background-design_1297-73.jpg);
}
div.mod_breadcrumb {
height: 40px;
margin: 0;
padding-top: 5px;
padding-right: 30px;
padding-bottom: 5px;
background-color: #e3e3e3;
padding-left: 8%;
}
.mod_breadcrumb ul li {
height: 30px;
display: inline-block;
padding: 3px 0;
color: #828282;
}
.test-wrap {
display: table;
width: 100%;
}
<div class="inside">
<div class="test-wrap">
<div class="ce_text chapo">
<h1>My header</h1>
<div class='text-chapo'>
<p>Lorem ipsum dolor sit Lorem ipsum dolor sit amet, consectetur adipiscing </p>
</div>
</div>
<div class="img_header"></div>
</div>
<div class="mod_breadcrumb block">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
This CSS it's ok... the 'float:left' option and relative width are different.
Here, I disccount the paddings left and right of total width. The float is necessary to horizontal align.
body,
div {
margin: 0;
padding: 0;
font-family: 'Roboto condensed', sans-serif;
}
div.inside {
position: relative;
}
div.chapo {
background-image: none;
width: 50%;
height: 255px;
vertical-align: top;
background-color: #aaa;
color: #fff;
padding: 20px 10%;
position: relative;
float: left;
}
h1 {
margin-top: 0;
font: 1.4em 'Oswald', Helvetica, sans-serif;
font-weight: bold;
text-transform: uppercase;
}
div.chapo p {
width: 100%;
position: relative;
padding: 0;
font-size: 1em;
font-weight: 300;
}
div.img_header {
width: 30%;
position: relative;
height: 295px;
vertical-align: top;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
float: left;
-webkit-background-size: cover;
background-image: url(https://image.freepik.com/free-psd/abstract-background-design_1297-73.jpg);
}
div.mod_breadcrumb {
height: 40px;
margin: 0;
padding-top: 5px;
padding-right: 2%;
padding-bottom: 5px;
background-color: #e3e3e3;
padding-left: 8%;
float:left;
width:90%;
}
.mod_breadcrumb ul li {
height: 30px;
display: inline-block;
padding: 3px 0;
color: #828282;
}
Try like this:
You have to define float property as well as you must define height:255px (as for another div you have given height as 255px )for your img_header class. It's really necessary.
body,
div {
margin: 0;
padding: 0;
font-family: 'Roboto condensed', sans-serif;
box-sizing: border-box
}
div.inside {
position: relative;
}
div.chapo {
background-color: #ef4056;
background-image: none;
width: 70%;
float:left;
height: 255px;
display: table-cell;
vertical-align: top;
background-color: #aaa;
color: #fff;
padding: 20px 8%;
position: relative;
}
h1 {
margin-top: 0;
font: 1.4em 'Oswald', Helvetica, sans-serif;
font-weight: bold;
text-transform: uppercase;
}
div.chapo p {
width: 100%;
min-width: 100%;
position: relative;
padding: 0;
font-size: 1em;
font-weight: 300;
}
.clearfix {
clear:both;
}
.img_header {
width: 30%;
height: 255px;
float: right;
position: relative;
display: table-cell;
vertical-align: top;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
-webkit-background-size: cover;
background-image: url(https://image.freepik.com/free-psd/abstract-background-design_1297-73.jpg);
}
div.mod_breadcrumb {
height: 40px;
margin: 0;
padding-top: 5px;
padding-right: 30px;
padding-bottom: 5px;
background-color: #e3e3e3;
padding-left: 8%;
}
.mod_breadcrumb ul li {
height: 30px;
display: inline-block;
padding: 3px 0;
color: #828282;
}
<div class="inside">
<div class="ce_text chapo">
<div class='text-chapo'>
<h1>My header</h1>
<p>Lorem </p>
<p>Aliquam porttitor.</p>
</div>
</div>
<div class="img_header"></div>
<div class="mod_breadcrumb block">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
<div class="clearfix"></div>
Hey guys i am trying to move my submit button to a input field, but its like mission impossible. Only way i can do is with position: absolute or relative and it looks horrible when i change resolution.
You can find live version on:
http://funedit.com/andurit/try1/
My CSS:
body{
margin: 0 auto;
padding: 0 auto;
background-image:url('images/background.png');
background-repeat: no-repeat;
background-size 100%;
background-position: 50% 0;
margin: 0 auto;
font-size: 13px;
font-family: Arial;
min-width: 1160px;
}
.center {
width: 1030px;
margin: 0 auto;
}
#top-panel{
background-image:url('images/top_panel.png');
background-repeat: repeat-x;
position: fixed;
min-width: 1160px;
background-size: 100%;
width: 100%;
height: 48px;
line-height: 48px;
background-position: 50% 0;
padding: 0 auto;
}
#top-button{
background-image:url('images/top_button.png');
background-repeat: no-repeat;
display: inline-block;
width: 141px;
height: 38px;
margin: 5px auto 5px 20px;
}
#top-panel #text{
color: #9c9c9c;
vertical-align:top;
}
#top-panel #text b{
font-weight: bold;
vertical-align:top;
}
#top-panel #text2{
color: #6ab1ed;
vertical-align:top;
white-space: nowrap;
margin-left: 50px; /* Horny panel, medzera medzi textami */
}
#top-panel #text3{
color: #9c9c9c;
vertical-align:top;
}
#top-panel input{
height: 22px;
line-height: 22px;
text-align: center;
vertical-align:top;
margin-top: 10px;
}
#top-panel #login-button{
height: 27px;
width:81px;
display: inline-block;
margin-top: 9px;
margin-left: 2px;
vertical-align:top;
}
#warningimg{
background-image: url("images/warning.png");
background-repeat: no-repeat;
position: relative;
left: 720px;
top: 50px;
width: 37px;
height: 35px;
}
a #warning{
color: #d4d4d4;
height:35px;
display: block;
text-align: right;
margin-top: 30px;
margin-right: 15px;
text-decoration:none;
}
#warning #underline{
text-decoration:underline;
}
#container{
width: 1027px;
height: 1456px;
background-color:#d4d4d4;
display:inline-block;
}
#logobg{
background-image: url("images/logobg.png");
background-repeat: repeat-x;
height:84px;
margin: 9px 22px;
}
#logo{
background-image: url("images/logo.png");
background-repeat: no-repeat;
width: 285px;
height: 74px;
display: inline-block;
margin: 5px 0 0 10px;
line-height: 74px;
}
#logobg input[type="text"]{
width: 273px;
height: 39px;
line-height: 39px;
border: 2px;
border-color: #d4d4d4;
vertical-align:middle;
position: relative;
left: 350px;
bottom: 35px;
display: table-cell;
}
/*
#search-submit{
background-image: url("images/search_submit.png");
background-repeat: no-repeat;
width:48px;
height: 41px;
display: inline-block;
margin-left: 900px;
margin-bottom: 10px;
}
*/
#logobg .search-submit input {
background:url(images/search_submit.png) no-repeat;
cursor:pointer;
width: 48px;
height: 41px;
border: none;
display:inline-block;
margin-left: 700px;
margin-bottom: 700px;
}
HTML:
<body>
<div id="top-panel">
<div class="center">
<span id="top-button"></span>
<span id="text"> Právě hraje <b>5000</b> hráčů na <b>150</b> serverech</span>
<span id="text2"> Registruj se zdarma </span> <span id="text3"> nebo </span>
<input type="text">
<input type="password">
<span id="login-button"><img src="images/login_button.png"></span>
</div>
</div>
<div class="center">
<div id="warningimg"></div>
<span id="warning"><span id="underline">NIGHT CUP 2014</span>- Sledujte přímý přenos</span>
</div>
<div class="center">
<div id="container">
<div id="logobg">
</span>
<input type="text">
<div class="search-submit"><INPUT type="submit" name="" value=""></div>
</div>
</div>
</div>
</body>
So please is here anybody who can fix it for me?
p.s. I think its on different line of block or something because i cant move it even with high margin , pading values
Hi your problem is that you have the submit in a div. May I ask why your text input is not in a <form>?
Try this css.
#logobg .search-submit input {
background: url("images/search_submit.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
border: medium none;
cursor: pointer;
display: inline-block;
height: 41px;
line-height: 39px;
margin-right: 20px;
margin-top: 20px;
width: 48px;
}
.search-submit {
display: inline;
float: right;
}
This jsFiddle should solve your problem. I have tried resizing it on a few screens and it has stayed in the right place. I changed and added some so styles to the search submit class.
#logobg .search-submit{
width: 48px;
height: 41px;
display: inline-block;
margin-left: 350px;
margin-top: 20px;
position: absolute;
}
#logobg .search-submit input {
background: url(http://funedit.com/andurit/try1/images/search_submit.png) no-repeat;
cursor: pointer;
width: 48px;
height: 41px;
border: none;
}
My current problem is that I have three div elements; one floated left, one floated right, and one between those two. I want the center div to automatically stretch to the max width of the width available between the two divs.
HTML
<div id="contain">
<div id="left">1</div>
<div id="filler"></div>
<div id="right">2</div>
</div>
CSS
#left {
text-decoration: none;
display: inline-block;
float: left;
width: auto;
padding: 0px 20px 0px 20px;
height: 45px;
text-align: center;
line-height: 300%;
background: #FF9000;
color: #FFFFFF;
}
#navFiller {
display: inline-block;
position: fixed;
float: left;
width: auto;
height: 45px;
background: #FF9000;
}
#right {
text-decoration: none;
display: inline-block;
float: right;
width: auto;
padding: 0px 20px 0px 20px;
height: 45px;
text-align: center;
line-height: 300%;
background: #FF9000;
color: #FFFFFF;
}
#contain {
width: 100%;
height: 45px;
padding: 0;
margin: 0;
display: inline;
}
Jsfiddle of project:
http://jsfiddle.net/msEBU/
If you add your filler element after the floated elements, and then change up its styles a little bit (including giving the style-block the correct id), you can get what you're going for:
#left {
display: inline-block;
float: left;
padding: 0px 20px 0px 20px;
height: 45px;
text-align: center;
line-height: 300%;
background: #FF9000;
color: #FFFFFF;
}
#filler {
display: block;
float: none;
height: 45px;
background: #F00;
}
#right {
display: inline-block;
float: right;
padding: 0px 20px 0px 20px;
height: 45px;
text-align: center;
line-height: 300%;
background: #FF9000;
color: #FFFFFF;
}
#contain {
width: 100%;
height: 45px;
padding: 0;
margin: 0;
display: inline;
}
<div id="contain">
<div id="left">1</div>
<div id="right">2</div>
<div id="filler">m</div>
</div>
OR, simulate a table:
#contain {
width: 100%;
padding: 0;
margin: 0;
display: table;
}
#left,
#right {
text-decoration: none;
display: table-cell;
width: 5%;
text-align: center;
background: #FF9000;
color: #FFFFFF;
padding: 2% 0;
}
#filler {
display: table-cell;
width: auto;
background: #F00;
}
<div id="contain">
<div id="left">1</div>
<div id="filler">m</div>
<div id="right">2</div>
</div>
Both methods have their benefits. It's up to you which is right for you.
Many implementations of CSS do not support automatic sizing relationships between different float layers. There are many solutions though. My recommendation is to use a small bit of javascript. I've used the following line of Jquery with some minor css tweaks:
$('#filler').outerWidth($('#contain').width()-$('#right').outerWidth()-$('#left').outerWidth());
Fiddle:
http://jsfiddle.net/K9C4u/2/
Also note that I moved the divs onto the same line because it makes a text node with a space for each of the return+tabs.
I'm having a problem with my center button (image) collapsing on itself; it is not showing the image (width: 200px) in all of it's glory. Also, for some reason, my previous and next arrows are not showing up properly either (only 2px by 20px, as opposed to the full image). I'd truly appreciate any insight because I've been battling with this for a few hours now; I'm sure it's human error because it happens in "The Big 4" (IE, Chrome, FF and Opera). Also, I attached an image to help clearly illustrate the issue...
My HTML is as follows:
<div class="excerpt">
...
<div class="buttons">
The Challenge
The Solution
Our Expertise
</div><!-- end .buttons -->
<div class="pagination">
1
2
3
4
5
</div><!-- end .pagination -->
</div><!-- end #rotator -->
The CSS for the above is as follows:
#rotator .excerpt {
float: left;
width: 320px;
margin: 0 0 0 40px;
}
#rotator .buttons {
text-align: center;
font-size: 20px;
clear: both;
padding-top: 15px;
width: 100%;
}
#rotator .button {
width: 200px;
height: 40px;
background-image: url(images/btn.gif);
background-repeat: no-repeat;
padding: 3px 0 0 0;
text-indent: -20px;
}
#rotator .button.active {
background-image: url(images/active-btn.gif);
background-repeat: no-repeat;
}
#rotator .button.right {
margin-right: -5px;
}
#rotator .pagination {
clear: both;
text-align: center;
font-size: 1.2em;
font-weight: bold;
padding-top: 10px;
width: 100%;
}
#rotator .pagination a.prev {
height: 30px;
width: 30px;
text-indent: -9999px;
background-image: url(images/page-left.png);
background-repeat: no-repeat;
margin-right: 10px;
}
#rotator .pagination a.next {
height: 30px;
width: 30px;
text-indent: -9999px;
background-image: url(images/page-right.png);
background-repeat: no-repeat;
margin-left: 10px;
}
#joe; a in an inline tag not a block tag & inline tag is not take any height, width & vertical margin & padding. So, define display:block in your prev & next anchor button.
CSS:
#rotator .pagination a.prev,
#rotator .pagination a.next{
display:block;
}