Understanding CSS Grouping/ Nesting - html

I know similar questions to this have been asked a bunch of times but I could not find an answer for my specific one. If I have a bunch of CSS selectors that are very similar but are only just different how can I nest or group them.
Here is what I am trying to do.
#cell-left {
background-color:#DDDDDD;
border:2px solid;
height:400px;
margin:20px 10px 0px 32px;
padding: 40px 15px 15px 15px;
text-align:center;
}
#cell-center {
background-color:#DDDDDD;
border:2px solid;
height:400px;
margin:20px 10px 0px 10px;
padding: 40px 15px 15px 15px;
text-align:center;
}
#cell-right {
background-color:#DDDDDD;
border:2px solid;
height:400px;
margin:20px 32px 0px 20px;
padding: 40px 15px 15px 15px;
text-align:center;
}
#row {
width:100%;
margin-top:0px;
}
As you can see all the cells are very common to each other they just have slightly different margins. I know there is a way to do all the cells the exact same then add a .right, .center and .left with just margin in the CSS and cut down on a lot of code.
Thanks in advance for the answer.

Create a cell class which contains the duplicate properties and add it to each of the DOM elements.
CSS
.cell{
background-color:#DDDDDD;
border:2px solid;
height:400px;
padding: 40px 15px 15px 15px;
text-align:center;
}
#cell-left{
margin:20px 10px 0px 32px;
}
#cell-center {
margin:20px 10px 0px 10px;
}
#cell-right {
margin:20px 32px 0px 20px;
}
HTML
<div id="cell-left" class="cell">Something</div>
<div id="cell-right" class="cell">Something</div>
<div id="cell-center" class="cell">Something</div>
Example: http://jsfiddle.net/hKLMj/

If you have just one left, center and right cell then you are fine with the id.
Otherwise use classes, since id-s must be unique and you can't have two elementswith the same id on the page.
And here is the shortened version of your CSS. Since your cell-s are some kind of children (let's assume they're <td>-s of a <tr> with class .row) - you don't have to use classes. This will make your markup cleaner:
tr.row td {
background-color: #ddd;
border: 2px solid;
height: 400px;
padding: 40px 15px 15px 15px;
text-align:center;
margin:20px 10px 0px 10px;
}
also if there are 3 of them in a row you don't have to use classes for defining left and right:
tr.row td:first-child {
margin:20px 10px 0px 32px; /* left cell */
}
tr.row td:last-child {
margin:20px 32px 0px 20px; /* right cell */
}
And the HTML will be
<tr class="row">
<td> left cell </td>
<td> center cell </td>
<td> right cell </td>
</tr>
DEMO

I suggest you use class, it is the only way to group what you want. By the way, I guess you will have some pages with several identical cells and several rows, right ?
(I guess you know that, but in case : It is very bad practice to use twice a same id on a same page. Classes are meant to be used several times on a same page. And ids are meant to be used only once/page.
You can do this :
.cell {
background-color:#DDDDDD;
border:2px solid;
height:400px;
padding: 40px 15px 15px 15px;
text-align:center;
}
.cell-left {
margin:20px 10px 0px 32px;
}
.cell-center {
margin:20px 10px 0px 10px;
}
.cell-right {
margin:20px 32px 0px 20px;
}
.row {
width:100%;
margin-top:0px;
}
And in you HTML you do this
<table border="1">
<tr class="row">
<td class="cell cell-left">row 1, cell 1</td>
<td class="cell cell-right">row 1, cell 2</td>
</tr>
<tr class="row">
<td class="cell cell-left">row 2, cell 1</td>
<td class="cell cell-right">row 2, cell 2</td>
</tr>
</table>
You can chain classes

CSS does not support grouping or nesting. Now, some CSS compilers (e.g. LESS, SASS) support such concepts as well as "mixins" and other neat tricks ..
.. however, remember that all matching CSS rules are applied. The selector specificity and order of declaration only decide which values override others. So, without classes or other hullabaloo:
#cell-left, #cell-center, #cell-right, #row {
background-color:#DDDDDD;
border:2px solid;
height:400px;
padding: 40px 15px 15px 15px;
}
#cell-left, #cell-center, #cell-right {
text-align: center;
}
#cell-left {
margin:20px 10px 0px 32px;
}
#cell-center {
margin:20px 10px 0px 10px;
}
#cell-right {
margin:20px 32px 0px 20px;
}
#row {
width:100%;
margin-top:0px;
}
Now, while it might be beneficial to use classes or a cleaner markup - especially if doing so leads to easier maintenance - the above will achieve the same result as the initial post. YMMV.

It will be more semantically correct to use double class selectors:
.cell {
background-color: #DDDDDD;
border: 2px solid;
height: 400px;
padding: 40px 15px 15px 15px;
text-align: center;
}
.cell.left {
margin: 20px 10px 0px 32px;
}
.cell.center {
margin: 20px 10px 0px 10px;
}
.cell.right {
margin: 20px 32px 0px 20px;
}
This way you will be able to write:
<div class="cell left">Something</div>
<div class="cell center">Something</div>
<div class="cell right">Something</div>
Or even:
<div class="left cell">Something</div>
<div class="center cell">Something</div>
<div class="right cell">Something</div>

Related

How to center a div within a div? (margin: 0 auto; not working)

I have a div that is going to be used as a button, but it doesn't want to center within the larger div!
This is my CSS for the larger div:
.news-quarters{
width:189px;
height:300px;
position:relative;
float:left;
padding:10px;
padding-top:0px;
margin:10px;
text-align:left;
}
and for the button div:
.green-button{
width:auto;
height:auto;
position: relative;
float:none;
padding:0px;
margin: 0 auto;
background: #0A9C00;
background-size:auto;
border:1px outset #0A9C00;
border-radius: 3px;
-webkit-box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
-moz-box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
overflow:auto;
display:inline-block;
}
.green-button h4{
text-align:center;
color:white;
line-height:1;
margin:0px;
font-size:12px;
padding-bottom: 5px;
padding-left: 10px;
padding-right: 10px;
padding-top: 5px;
width:auto;
}
And my html like this:
<div class="news-quarters">
<div class="green-button">
<h4>Insert button text here</h4>
</div>
</div>
Can someone please help? This is severely p***ing me off :(
Thank you!
In the style .news-quarters change text-align:left to text-align:center;
There are already many existing answers for this problem see How to horizontally center a <div> in another <div>?

how to center the button inside a table cell

I'm trying to center a button inside the table by : text-align: center
However, it seems doesn't work for me.
Note: I used Display: table-cell combine with Vertical-align: middle to center the text of the button. As you can see the text of the first button "AAAAAAA" is in the middle.
Can someone help me to center the button without affecting the text of the button.
Thank you in advance.
Here's the example code:
http://codepen.io/anon/pen/pAcBx
I usually do
margin:auto;
display:block;
I guess #rhino answer works as well. Remember to remove
display:table-cell;
EDIT:
Keep in mind that doing this will get the a element content vertically centered, but if you also give the a element an arbitrary height, the surrounding background will not be centered.
Example 1: the text is vertically centered. But you set the button height to 32px and that surrounding container isn't:
table, tr, td{
border: solid;
}
.my_table {
width: 312px;
margin: 0 auto;
}
.dashed {
border-bottom:1px dashed #99F;
width:100%;
display:block;
position:absolute;
font-size:0;
top:43px;
}
/*BUTTON TABLE left CELL*/
.left_button_cell{
margin: 0 auto;
text-align: center; /*<---- NOT WORKING */
height: 50px;
padding-top: 10px;
line-height: 22px;
}
/*BUTTON TABLE right CELL*/
.right_button_cell{
text-align: center;
height: 50px;
padding-top: 10px;
line-height: 22px;
}
.inner_button {
-moz-box-shadow:inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow:inset 0px 1px 0px 0px #ffffff;
box-shadow:inset 0px 1px 0px 0px #ffffff;
background-color:#fbfbfb;
-webkit-border-top-left-radius:8px;
-moz-border-radius-topleft:8px;
border-top-left-radius:8px;
-webkit-border-top-right-radius:8px;
-moz-border-radius-topright:8px;
border-top-right-radius:8px;
-webkit-border-bottom-right-radius:8px;
-moz-border-radius-bottomright:8px;
border-bottom-right-radius:8px;
-webkit-border-bottom-left-radius:8px;
-moz-border-radius-bottomleft:8px;
border-bottom-left-radius:8px;
text-indent:0;
border:2px solid #dcdcdc;
display:block;
margin:auto;
color:#939393;
font-family:arial;
font-size:15px;
font-weight:normal;
font-style:normal;
height:32px;
line-height:16px;
width:104px;
text-decoration:none;
text-align:center;
text-shadow:1px 1px 0px #ffffff;
word-wrap:break-word;
vertical-align:middle;
}
.inner_button:hover {
background-color:#EBEBEB;
}
.inner_button:active {
position:relative;
top:1px;
}
<div class="dashed"></div>
<table class="my_table">
<tbody>
<tr>
<td class="left_button_cell">
<a class="inner_button" href="#">AAAAAAAA</a>
</td>
<td class="right_button_cell">
<a class="inner_button" href="#">BBBBBBBB BBBBBBBB</a>
</td>
</tr>
</tbody>
</table>
You could set the line-height to be also 32px, which would work for the first button, but the second one would break. Also, you could set a button padding of 6px to achieve the same result without declaring an explicit height (as css frameworks like bootstrap or materialize do) but the line break on the second button would result in uneven button sizes.
So, here's my suggested trick: set the a element line height to be 32px, then wrap its inner text in a span element where you reset the line-height to 16px:
table, tr, td{
border: solid;
}
.my_table {
width: 312px;
margin: 0 auto;
}
/*BUTTON TABLE left CELL*/
.left_button_cell{
margin: 0 auto;
text-align: center; /*<---- NOT WORKING */
height: 50px;
padding-top: 10px;
line-height: 22px;
}
/*BUTTON TABLE right CELL*/
.right_button_cell{
text-align: center;
height: 50px;
padding-top: 10px;
line-height: 22px;
}
.inner_button {
-moz-box-shadow:inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow:inset 0px 1px 0px 0px #ffffff;
box-shadow:inset 0px 1px 0px 0px #ffffff;
background-color:#fbfbfb;
-webkit-border-top-left-radius:8px;
-moz-border-radius-topleft:8px;
border-top-left-radius:8px;
-webkit-border-top-right-radius:8px;
-moz-border-radius-topright:8px;
border-top-right-radius:8px;
-webkit-border-bottom-right-radius:8px;
-moz-border-radius-bottomright:8px;
border-bottom-right-radius:8px;
-webkit-border-bottom-left-radius:8px;
-moz-border-radius-bottomleft:8px;
border-bottom-left-radius:8px;
text-indent:0;
border:2px solid #dcdcdc;
display:block;
margin: 0 auto;
color:#939393;
font-family:arial;
font-size:15px;
font-weight:normal;
font-style:normal;
height:32px;
line-height:32px;
width:104px;
text-decoration:none;
text-align:center;
text-shadow:1px 1px 0px #ffffff;
word-wrap:break-word;
vertical-align:middle;
}
.inner_button span {
line-height:16px;
display:inline-block;
}
.inner_button:hover {
background-color:#EBEBEB;
}
.inner_button:active {
position:relative;
top:1px;
}
<table class="my_table">
<tbody>
<tr>
<td class="left_button_cell">
<a class="inner_button" href="#">
<span>AAAAAAAA
</span>
</a>
</td>
<td class="right_button_cell">
<a class="inner_button" href="#">
<span>BBBBBBBB BBBBBBBB</span>
</a>
</td>
</tr>
</tbody>
</table>
EDIT 2019
You can achieve the same using flexbox. However, this means the border-spacing property does no longer apply so you need to do some fine tuning to the cell margins.
Basically, you set flex properties as:
.my_table tr {
display:flex;
}
.my_table td {
margin: 2px;
height: 60px;
display:flex;
flex-grow:1;
/* centering the button */
align-items:center;
justify-content:center;
}
.inner_button {
display:flex;
/* centering the text inside the button */
align-items:center;
justify-content:center;
/* plus the other properties */
}
With this you no longer need playing with spans, and the alignment of children is controlled explicitly.
table, td{
border: solid;
}
.my_table {
width: 312px;
margin: 0 auto;
}
.my_table tr {
display:flex;
}
.my_table td {
margin: 2px;
height: 60px;
display:flex;
flex-grow:1;
align-items:center;
justify-content:center;
}
.inner_button {
align-items:center;
justify-content:center;
display:flex;
width:104px;
box-shadow:inset 0px 1px 0px 0px #ffffff;
background-color:#fbfbfb;
text-align:center;
border-radius:8px;
border:2px solid #dcdcdc;
color:#939393;
font-family:arial;
font-size:15px;
height:45px;
text-decoration:none;
text-shadow:1px 1px 0px #ffffff;
word-wrap:break-word;
}
.inner_button:hover {
background-color:#EBEBEB;
}
.inner_button:active {
position:relative;
top:1px;
}
<table class="my_table">
<tbody>
<tr>
<td class="left_button_cell">
<a class="inner_button" href="#">
AAAAAAAA
</a>
</td>
<td class="right_button_cell">
<a class="inner_button" href="#">
BBBBBBBB BBBBBBBB
</a>
</td>
</tr>
</tbody>
</table>
Anyway, once you switch to this layout there's no reason to stick to tables, and you might as well convert your layout to divs.
Change display: table-cell to display: inline-block:
.inner_button {
/* ... */
display: inline-block;
/* ... */
}
I added this to the TableCell and it centered my ImageButton. I think we were running into the same issue.
<asp:TableCell HorizontalAlign="Center" style="padding: 0px;">
<asp:ImageButton/>
</asp:TableCell>
Found my answer here: http://forums.asp.net/t/1418752.aspx?image+button+inside+table+cell
You can use the table-cell display property of the container div and set the vertical-align property to middle:
HTML
<div id="table">
<div class="row">
<div class="cell">
I'm your button
</div>
</div>
</div>
CSS
#table {
width: 300px;
display: table;
background: red;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
height: 200px;
background: yellow;
vertical-align: middle;
text-align: center;
}
You can find the fiddle here.
this works
td{
align:center;
}
simple and easy... hope it helps

button not staying within div

I have a <div> and a <button>, but for some reason, the button will not stay in the div.
I have tried to clear the div, as well as float: left but it has not helped.
I have also added padding to the bottom of the div, but I don't think that is the solution.
My code:
<div class="service-text text2">
<p>
this is some text
</p>
<i class="fa fa-credit-card" style="padding-right:10px;"></i> Learn More
</div>
JSFiddle
Usually parent div set its height auto to its child heights, but padding you assigned to button-learn is causing the issue.
you just need to set display:inline-block; on your anchor tag
An inline-block element is placed as an inline element (on the same line as adjacent content), but it behaves as a block element.
.button-learn {
margin: 2px;
position:relative;
text-align: center;
border-radius:4px;
text-decoration: none;
font-family:'PT Sans',helvetica;
background: #69c773;
display:inline-block;
font-size: 17px !important;
padding: 10px 10px 10px 10px;
color: #FFF;
}
Here is fiddle
Floating both the elements seems to do what you want, unless you want the button to be next to the text.
add these:
.service-text {
float: left;
}
.button-learn {
float:left;
}
or check: http://jsfiddle.net/Milanzor/Qt9u3/4/
working demo
Set document height first:
body, html {
height:100%
}
then set .service-text height:
.service-text {
margin:0;
width:100%;
height:100%; /* change this from auto */
display:block;
background-color:#34495e;
-moz-border-radius: 0px;
-webkit-border-radius: 0px 0px 5px 5px;
border-radius: 0px 0px 5px 5px;
}
and it works!! :)
EDIT
div inside another div
HTML
<div id="parent">
<div class="service-text text2">
<p>this is some text</p>
<i class="fa fa-credit-card" style="padding-right:10px;"></i> Learn More
CSS
body, html {
height:100%;
margin:0;
padding:0;
}
#parent {
height:100%; /* remove this and everything falls out of place*/
}
.service-text {
margin:0;
width:100%;
height:100%;
display:block;
background-color:#34495e;
-moz-border-radius: 0px;
-webkit-border-radius: 0px 0px 5px 5px;
border-radius: 0px 0px 5px 5px;
}
.service p {
margin:0;
padding-top:5px;
padding-bottom:10px;
padding-right:7px;
padding-left:15px;
font-family:'PT Sans', 'Arial', 'Open Sans';
font-size:14px;
line-height:22px;
color:white;
display: block;
position:relative;
}
.button-learn {
margin: auto;
position:relative;
text-align: center;
border-radius:4px;
text-decoration: none;
font-family:'PT Sans', helvetica;
background: #69c773;
font-size: 17px !important;
padding: 10px 10px 10px 10px;
color: #FFF;
}
.button-learn:hover {
color: #51A65F;
}
</div>
</div>
Explaination : you just need to set the height of the div always, once you set it.....you'll get the desired view!

Pair of divs wrapping on Firefox

I'm creating a box containing some image links, and currently I've got something that looks great on Chrome and Safari, but wraps at Firefox's default zoom level. Zooming in makes the box look fine, but at the normal zoom level they're wrapped. Here's what it looks like normally, on Chrome:
...and this is how it looks on Firefox:
The strange thing about this is that the right box isn't completely wrapped: some of the top and bottom borders are visible on the first line and I can't make sense of why it is wrapped at this particular point. This is what the HTML looks like:
<div class="clearfix buyTrackContainer">
<div class="buyTrackBox">
<p>Buy this Track</p>
<div class="buyLinksBox">
<div class="buyLinksBoxLeft">
<div class="d-itunes"></div>
</div>
<div class="buyLinksBoxRight">
<div class="d-amazon"></div>
</div>
</div>
</div>
<div class="buyTrackBox">
<p>Buy on Vinyl/CD</p>
<div class="buyLinksBox">
<div class="buyLinksBoxLeft">
<div class="b-ebay"></div>
</div>
<div class="buyLinksBoxRight">
<div class="b-amazon"></div>
</div>
</div>
</div>
...and the relevant CSS is as follows:
.buyTrackContainer {
text-align: center;
}
.buyTrackBox {
display:inline-block;
border:1px solid #ddd;
padding-left: 3px;
padding-right: 3px;
padding-top: 1px;
padding-bottom: 5px;
width:46%;
text-align:left;
background-color: #fff;
border-radius: 3px;
border-bottom:3px solid #ddd;
}
.buyLinksBoxLeft {
display:inline;
border: 1px solid #ddd;
border-bottom: 3px solid #ddd;
border-radius: 3px 0px 0px 3px;
padding: 12px 4px 8px 8px;
text-align:center;
vertical-align:center;
background-color:#fff;
}
.buyLinksBoxRight {
display:inline;
border: 1px solid #ddd;
border-bottom: 3px solid #ddd;
border-radius: 0px 3px 3px 0px;
border-left:0px;
padding: 12px 8px 8px 4px;
text-align:center;
vertical-align:center;
background-color:#fff;
}
.buyLinksBox {
display:block;
text-align:center;
padding-bottom:10px;
padding-top:8px;
}
div.d-itunes {
display:inline-block;
margin-left:0px;
width:50px;
height:17px;
background:url(/images/misc/iTunes-buy-button.png) no-repeat;
}
div.d-amazon {
display:inline-block;
margin-left:0px;
width:50px;
height:17px;
background:url(/images/misc/Amazon-buy-button.png) no-repeat;
}
div.b-ebay {
display:inline-block;
margin-left:0px;
width:50px;
height:17px;
background:url(/images/misc/eBay-buy-button.png) no-repeat;
}
I'm relatively new to proper CSS design so I'd appreciate any pointers about how I could improve my coding style. Does anyone know what might be happening here that could cause this?
Ill try with the first container change the add the following to
.buyTrackBox {
white-space:nowrap
}
.buyLinksBoxLeft {
float:left;
}
.buyLinksBoxRight {
float:right;
}
More over try dividing the width of buyLinksBoxLeft and buyLinksBoxRight in percentages so as to fit th parent container some thing around 40% may do. do the same with the buyLinksBox div and children
on your class, 'buyLinksBoxLeft' & 'buyLinksBoxRight' change
display: inline;
to
display: inline-block;
fiddle: http://jsfiddle.net/aqAVy/
That should sort it out.
Avoid redundancy in names... eg. change .BuyLinksBoxRight (son of .BuyLinksBox) to just .right (same with .left)
When multiple items has a lot of common properties, group them in a common selector.
Use oneliner paddings and borders when you can.
Code will be more readable and problems will vanish.
Running Demo
.buyTrackContainer {
text-align : center;
}
.buyTrackContainer > div,
.buyLinksBox > div {
display : inline-block;
border : 1px solid #ddd;
}
.buyTrackBox {
background-color : #fff;
border-bottom : 3px solid #ddd;
border-radius : 3px;
text-align : left;
padding : 1px 3px 5px 3px;
width : 134px;
}
.buyLinksBox {
padding-bottom : 10px;
padding-top : 8px;
text-align : center;
}
.buyLinksBox > div {
background-color : #fff;
vertical-align : center;
border-bottom : 3px solid #ddd;
text-align : center;
}
.buyLinksBox > .left {
border-radius : 3px 0px 0px 3px;
padding : 12px 4px 8px 8px;
}
.buyLinksBox > .right {
border-radius : 0px 3px 3px 0px;
border-left : 0px;
padding : 12px 8px 8px 4px;
}
.buyLinksBox > div > a > div {
margin-left : 0px;
height : 17px;
width : 50px;
}
div.d-amazon, div.b-amazon {
background : url(/images/misc/Amazon-buy-button.png) no-repeat;
}
div.d-itunes {
background : url(/images/misc/iTunes-buy-button.png) no-repeat;
}
div.b-ebay {
background : url(/images/misc/eBay-buy-button.png) no-repeat;
}

position of website elements

I have an issue with rendering my website for IE, Chrome and Opera. In Firefox the positioning works well:
while in the other browsers it looks like crap:
I have tried several positioning and padding options, but no luck. The problems appeared as I replaced the drop down menu with a jQuery replacement to enhance it graphically. The original dropdown is still there but with the css-option "display: none". I'd be thankful for a hint!
Here is the css:
This is the big blue box
.searchHomeForm a, .searchHomeForm a:hover {
color:#000000;
}
A invisible box around the three elements
div.searchHomeForm , .searchform {
height: 37px;
margin-left: auto;
margin-right: auto;
}
The white search bar
.search_bar {
position: inherit;
height: 25px;
letter-spacing: 0.02em;
line-height: 25px;
padding: 9px 0 0px 9px;
width: 390px;
border: 1px solid #95B6D6;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.11) inset;
border-radius: 0.25em 0 0 0.25em;
}
the jQuery Dropdown replacement
#searchformReplacement {
background: #EBEBEB;
padding: 0px 1px 5px 0;
margin-bottom: 3px;
border-top: 1px solid #95B6D6;
border-bottom: 1px solid #95B6D6;
width: 109px;
position: inherit;
}
the find button
.find_button {
background: url("../images/lupevufindsearchsubmit1.png") no-repeat scroll #bBbBbB;
-moz-border-radius: 0.25em;
border-radius: 0 0.25em 0.25em 0;
position: inherit;
height: 36px;
line-height: 36px;
margin: 0px 0 3px -1px;
padding: 4px 10px 4px 10px;
width: 60px;
border-top: 1px solid #95B6D6;
border-right: 1px solid #95B6D6;
border-bottom: 1px solid #95B6D6;
border-left: none;
box-shadow: 2px 2px 5px rgba(76, 133, 187, 0.50) inset;
transition: all 0.2s ease-in-out 0s;
}
Try removing position: inherit from the .search_bar {}, #searchformReplacement {}and .find_button {} add display:inline-block for each
or add display:inline and float:left for each. You may have to clear floats if you use float:left
maybe use float: left; on the three elemetns next to each other?
I made you a little example to have the required position, I'm using the inline-block propriety (and I love it) :
Html
<div id="container">
<input type="text" class="inline-block" />
<div class="inline-block">
Your custom select
</div>
<button type="submit" class="inline-block">Search</button>
</div>
CSS
.inline-block {
display:inline-block;
*display:inline; /*IE hack*/
*zoom:1; /*IE hack*/
}
#container {
background:lightBlue;
width:300px;
margin:0 auto;
text-align:center;
}
See the working fiddle !
Yes, clearing your floats are important as madhushankarox has pointed out. But you don't always need to use floats, especially not in your case. Plus here's an extra bonus if you ever need to place your form into a liquid layout page. It should proportion itself out equally on most screens that are wide or thin.
CSS
/*the blue rounded box*/
#bluebox {
padding:3% 5%;
margin:0 25%;
background:#d0dcea;
border:solid 1px #b7c2d2;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
.fieldset-search {
text-align:center;
}
/*The white search bar*/
.input-search {
padding:5px;
margin:0;
width:50%;
vertical-align: baseline;
border: solid 1px #b7c2d2;
background: #fff;
outline: 0;
}
/*the jQuery Dropdown replacement*/
.list-search {
padding:4px;
margin:0 0 0 -5px;
}
/*the find button*/
.submit-search {
padding:4px 10px;
margin:0 0 0 -5px;
}
HTML
<div id="bluebox">
<div class="fieldset-search">
<input type="text" name="search" class="input-search">
<select name="list" class="list-search"><option></option></select>
<button type="search" class="submit-search">Go</button>
</div>
</div>