Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your question does not fit the Q&amp;A format, but I felt altruist and maked <a href="http://jsfiddle.net/vFzkM/" rel="nofollow">an example to you</a></p> <h2>HTML Observations</h2> <ul> <li>You should use background-images instead <code>&lt;img&gt;</code> tags for this effect, the image is not, semantically speaking, content.</li> <li>If the logo has a text layer then you should definitively use text for it.</li> <li><p>I assume you are using <code>cursor: pointer</code> because you are linking to somewhere - maybe the site home - so I recommend using an <code>&lt;a&gt;</code> tag for the container.</p> <pre><code>&lt;a id="logo" href="#"&gt; &lt;div class="text"&gt;Logo text&lt;/div&gt; &lt;div class="background"&gt;&lt;/div&gt; &lt;/a&gt; </code></pre></li> </ul> <h2>CSS observations</h2> <ul> <li>You are going too complex with positioning, your example will be difficult to integrate.</li> <li>Try using absolute positioning for the background image rather than for the container, see my example.</li> <li><p>If you define the <code>transition</code> behaviour for the <code>:hover</code> state, this behaviour will not affect the element on other state.</p> <pre><code>/** * Make logo width responsive to its text, * while staying as block. * Any absolute content will be relative to this * Remove the default underline for the &lt;a&gt; tag */ #logo { display: inline-block; position: relative; text-decoration: none; } /** * place the background layer on 0,0 * make them responsive to parent width and height * correct the z-index to display it behind the text * set transition time and easing */ #logo .background { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; -webkit-transition: all .5s ease; } /** * Just decoration for prettyness: * - Background image * - Text color * - Set a size which fits the bg image aspect ratio */ #logo .background { background: url("http://lorempixel.com/g/214/170/abstract/1") no-repeat; background-size: contain; } #logo .text { color: gold; width: 214px; height: 170px; } #logo:hover .background { margin-top: -20px; } </code></pre></li> </ul> <p>I hope my answer helps you</p>
 

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