css how to fix layout in table
Tags: css
Problem :
I am trying to get a few images in a table looking alright but there is an empty input on the 3rd row and 1st column. Also the input image types look slightly bigger? Edit: I forgot to mention this has also has to work for IE7 and up.
fiddle: http://jsfiddle.net/486EX/
style
input {
border: 1px solid black;
}
.emptyicon {
width: 37px;
height: 37px;
float: left;
font-size: 8px;
border: 1px solid grey;
}
.sizewidth {
width: 19px;
height: 10px;
padding: 5px 3px 8px 3px;
margin: 2px;
}
.showborder {
border: 2px solid red;
}
#product {
border: 1px solid #c1c1c1;
}
.sizebtn {
margin: 2px;
height: 31px;
width: 37px;
}
.icons {
width: 213px;
float: left;
padding: 2px;
}
.icons div {
padding: 2px;
float: left;
}
.icons input {
padding: 0;
cursor: pointer;
text-align: center;
background: #FFF;
color: #000;
display: block;
height: 37px;
width: 37px;
line-height: 37px;
font-size: .6em;
overflow: hidden;
}
.sizes {
float: left;
width: 213px;
}
.sizes div {
padding: 2px 0 0 2px;
float: left;
}
.sizes input {
padding: 0;
cursor: pointer;
text-align: center;
background: #FFF;
color: #000;
display: block;
height: 30px;
width: 30px;
font-size: 1.2em;
}
html:
<div id="product">
<table>
<tbody>
<tr>
<td>
<div id="icons_7934" class="icons">
<div>
<input id="imgcolor_7934_Amethyst" text="Amethyst" class="emptyicon showborder" type="button"
value="Amethyst">
</div>
<div>
<input id="imgcolor_7934_Aquamarine" text="Aquamarine" class="emptyicon " type="button"
value="Aquamarine">
</div>
<div>
<input id="imgcolor_7934_Baby_Pink" text="Baby Pink" class="emptyicon " type="button"
value="Baby Pink">
</div>
<div>
<input id="imgcolor_7934_Biscuit" text="Biscuit" class="emptyicon " type="button"
value="Biscuit">
</div>
<div>
<input id="imgcolor_7934_Bisque" text="Bisque" class="emptyicon " type="button" value="Bisque">
</div>
<div>
<input id="imgcolor_7934_Black" src="Images/black.jpg" class="emptyicon " type="image"
value="Black">
</div>
<div>
<input id="imgcolor_7934_Burnt_Orange" text="BurntOrange" class="emptyicon " type="button"
value="BurntOrange">
</div>
<div>
<input id="imgcolor_7934_Candy" text="Candy" class="emptyicon " type="button" value="Candy">
</div>
<div>
<input id="imgcolor_7934_Cherry" text="Cherry" class="emptyicon " type="button" value="Cherry">
</div>
<div>
<input id="imgcolor_7934_Deep_Lilac" text="DeepLilac" class="emptyicon " type="button"
value="DeepLilac">
</div>
<div>
<input id="imgcolor_7934_Dusty_Rose" text="DustyRose" class="emptyicon " type="button"
value="DustyRose">
</div>
<div>
<input id="imgcolor_7934_Iceblue" text="Iceblue" class="emptyicon " type="button"
value="Iceblue">
</div>
<div>
<input id="imgcolor_7934_Lime" text="Lime" class="emptyicon " type="button" value="Lime">
</div>
<div>
<input id="imgcolor_7934_Magenta" text="Magenta" class="emptyicon " type="button"
value="Magenta">
</div>
<div>
<input id="imgcolor_7934_Navy" text="Navy" class="emptyicon " type="button" value="Navy">
</div>
<div>
<input id="imgcolor_7934_Peacock" text="Peacock" class="emptyicon " type="button"
value="Peacock">
</div>
<div>
<input id="imgcolor_7934_Royal_Blue" text="RoyalBlue" class="emptyicon " type="button"
value="RoyalBlue">
</div>
<div>
<input id="imgcolor_7934_Teal" text="Teal" class="emptyicon " type="button" value="Teal">
</div>
<div>
<input id="imgcolor_7934_White" src="Images\White.jpg" class="emptyicon " type="image"
value="White">
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<script src="Scripts/jquery-1.8.2.min.js"></script>
<script>
$("[id^='imgcolor_7934']").live("click", function () {
$("[id^='imgcolor_7934']").removeClass('showborder');
$(this).addClass("showborder");
});
</script>
Solution :
I think your borders are throwing off the alignment. To correct, try using box-sizing:border-box;
Like so:
.emptyicon {
width: 37px;
height: 37px;
float: left;
font-size: 8px;
border: 1px solid grey;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
}
If you need to support ancient IE you can use this instead:
#imgcolor_7934_White, #imgcolor_7934_Black{
height:35px;
width:35px;
}
#imgcolor_7934_White.showborder, #imgcolor_7934_Black.showborder{
height:33px;
width:33px;
}
CSS Howto..
#logo would need to float: left then you should probably add a clear: both styled container after .secondardMenu or wrap them both with a clearfix class'd container...
The most common way to do this is something along these lines: ul { list-style: none; padding:0; margin:0; } li { padding-left: 1em; text-indent: -.7em; } li:before { content: "•...
I suggest to use an offset approach for centering the form horizontally. <div class="container"> <div class="row"> <div class="col-sm-6 col-sm-offset-3"> <!-- the form content --> </div> </div> </div> DEMO using your...
Seahorsepip's answer is fantastic. I made a lot of improvements on the non-fallback answer. http://jsfiddle.net/w1Lh4w2t/ I would recommend not doing that strange hidden png thing, when an Image object works...
Flexslider is pretty good for mobile. It has some custom functions for slide functionality and is responsive out-of-the-box. You can also do dynamic heights and looping by just setting some...
It seems there are some sort of image slider on your page. So what I will suggest you to include z-index also. #topnavbar { width:100%; height:50px; background-image:url('top.jpg'); background-repeat:repeat-x; position:fixed; z-index:500;...
Please try this HTML: (Change type= submit to type=button) <input type="button" name="create" class="enter submit" value="Enter" onclick="showDiv()" > CSS: (Change type= submit to type=button) .box2 input[type=button] { width: 100%; display: block;...
Yes, it's using CSS Media Queries. <style> @media (min-width: 701px) { //css for wide screen } @media (max-width: 700px) { //css for narrow screen } </style> ...
#topheader p{ margin: 20px; } see the space between the #topheader and the p ? it means p inside the topheader. you need to leave the #topheader { } as...
use rgba background. background: rgba(0, 0, 0, 0.5); values are in order red intensity, green intensity, blue intensity the decimal value is the opacity, and it runs from 0 to...
Masonry provides an item-selector option to avoid this kind of issues. I knew it but it turns out that AnimOnScroll add its own options when directly instantiating Masonry. The faulty...
Change background to background-image and it will work :) #image1 { background-image:url("http://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Bolognese_Image.jpg/180px-Bolognese_Image.jpg"); } #image2 { background-image:url("http://www.phy.duke.edu/~kolena/Recommended.gif"); } .myClass { width:180px; height:239px;...
Here's a pure css centering that's "almost" done. http://jsfiddle.net/gNanu/ It works for a dynamic amount of submenu items and centers properly as long as we have display: block on the...
The width on your hover is causing the jump. I moved it to the "a" tag and cleaned up the other code a bit as well: #city-navigation li a {...
Add 'float: left' to the first, and remove 'clear: both' from the second, a la http://jsfiddle.net/L2JgX/3/
Just an example: <div class="positionClass contentClass decorClass"> Lorem textum </div> .positionClass: here any position properties could be applyed, 4example absolute/fixed position, display properties, margin/negative margin. .contentClass : here we can...
Flexbox can do that: .chatbox { margin: 1em auto; width: 150px; height: 500px; border: 1px solid grey; display: flex; flex-direction: column-reverse; justify-content: flex-start; text-align: center; } .message { background: lightgreen;...
Put these condition to prevent multiple popup opening: function modal1() { if ($("#popup_2").is(":hidden")){ $('#popup_1').fadeIn(); } else{/*do something*/} } function modal2() { if ($("#popup_1").is(":hidden")){ $('#popup_2').fadeIn(); } else{/*do something*/} } Better way...
Remove the margin from the specific elements that shouldn't have it (the h4 and the ul of .menu-item). You can do this rather than using * as the selector. .menu-item...
Researching I've found an answer to my question. We need to use the rotateY attribute for the -webkit-transform CSS property. .imageRotateHorizontal{ -moz-animation: spinHorizontal .8s infinite linear; -o-animation: spinHorizontal .8s infinite...
The solution seems to be to add multiple @font-face rules, for example: @font-face { font-family: "DejaVu Sans"; src: url("fonts/DejaVuSans.ttf"); } @font-face { font-family: "DejaVu Sans"; src: url("fonts/DejaVuSans-Bold.ttf"); font-weight: bold; }...
This is fairly simple: Add the hamburger menu icon Have a CSS class that makes the nav area active Make JS add/remove that class from the nav area Use CSS...
If you two CSS rules with the same selectors, the second one loaded in the second style sheet is the one that will be used. This concept is known as...
Add to your theme's template.php file: function THEMENAME_css_alter(&$css) { unset($css[drupal_get_path('module','system').'/system.theme.css']); unset($css[drupal_get_path('module','system').'/system.base.css']); unset($css[drupal_get_path('module','system').'/system.menus.css']); } This is a pretty extreme...
To remove the corners set the data-corners="false" <select name="color" class="test" data-corners="false"> <option>pick a color</option> <option value="red">RED</option> <option value="blue">BLUE</option> </select> To hide the arrow, .ui-select .ui-icon { display:none; } To...
add to UL.tabs A border-bottom-color:rgb(221, 221, 221); border-bottom-style:solid; border-bottom-width:2px; ...
You need to give your middle container, appropriate padding,It will help bringing the content to the center. You can achieve the same by giving a left i.e. making your .middle...
Ok, answer was simple, all I had to do was to add one pseudo-class. ol{ list-style:none; font-family:sans-serif; } ol li{ padding:5px; margin:1px; background:#e6e6fa; } .classX{ text-align:center; } .classX a{ display:...
This is already a pretty old question. Although the answers given attended well at the time, nowadays the Flexible Box Layout offers the same result with much more simplicity, with...