I have a strange problem.One of my div's width is not working. My CSS is like
.product_info { margin-top:10px; background:#444; width:850px; } .product_image { width:350px; text-align:center; float:left; padding:8px; border:1px solid #e9e9e9; background:#fff; } .product_details { float:left; width:400px; margin-left:25px; font-size:14px; font-family:"Helvetica"; background:#d71414; }
And My HTML file is
<div class="product_info"> <div class="product_image"> </div> <div class="product_details"> <div class="selection"> <form action="{$path_site}{$indeex_file}" method="post"> Size {foreach name = feach item = k from = $product_size} <input type="radio" name="size" value="{$k.product_size}" />{$k.product_size} {/foreach} </div> <div class="selection"> No. of pieces <input type="text" name="quantity"> </div> <div class="prc"> <span class="WebRupee">Rs.</span> {$product_info->product_cost}.00 </div> <div class="buy_btn"><input type="submit" value="BUY" /></div> </form> </div> </div>
But as you can see in the attached image my div
product_info
's width is not 850px
, Whats wrong
To convert it to a fixed-width layout, simply add a fixed with to the #wrapper and set the margins to auto. Setting the margins to auto will cause the left and right margins to be equal no matter how wide the browser window is, which will cause your fixed-width layout to be positioned in the center of the browser.
What you could do is set your div to be position: absolute so your div is independent of the rest of the layout. Then say width: 100% to have it fill the screen width. Now just use margin-left: 30px (or whatever px you need) and you should be done.
While the display property is inline , height and width will not work. display :inline; By changing the display property from inline to block or inline-block , height and width should be worked properly.
display: flex
on the parent element also changes how width
and height
work. Disable shrinking/growing by flex: 0 0 auto;
, or use min-width
and max-width
instead.
Width and height basically lose the original meaning and will act as a flex-basis
, see geddski: The Difference Between Width and Flex Basis
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With