Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS wrap image or "center float"
    primarykey
    data
    text
    <p>I am using the following code to display a list of images and apply a drop shadow effect to each image. The images may vary in orientation but will always be a maximum of 120px.</p> <p>To get this to work I am having to float:left the "shadow" container. By adjusting the margins of the container and it's image, I am able to simulate a drop shadow. (<a href="http://img200.imageshack.us/i/withfloat.png/" rel="nofollow noreferrer">http://img200.imageshack.us/i/withfloat.png/</a>)</p> <p>The downside of this approach is that the image then becomes left aligned. If I remove the float the .shadow background spans the full width of the li and does not wrap the image. (see above url but "withoutfloat.png")</p> <p>How can I get the shadow div to wrap the image and keep it centered within the li?</p> <p>Css:</p> <pre><code>&lt;style type="text/css"&gt; ul { list-style-type: none; position: relative; margin: 0; padding: 0; } li.box { display: inline; float: left; margin: 3px; background: red; position: relative; } .wraptocenter { display: table-cell; text-align: center; vertical-align: middle; width: 120px; height: 120px; } .wraptocenter * { vertical-align: middle; } .shadow { background: blue; margin: 10px 0 0 10px !important; margin: 10px 0 0 5px; } .shadow img { margin: -4px 6px 6px -4px; } &lt;/style&gt; </code></pre> <p>Html:</p> <pre><code>&lt;ul&gt; &lt;li class="box"&gt; &lt;div class="wraptocenter"&gt; &lt;span&gt; &lt;div class="shadow"&gt; &lt;img src="Handler.ashx?id=936&amp;size=103" /&gt; &lt;/div&gt; &lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload