design - CSS: Display element with width "inline" -


I have an icon that I want to drop into text in arbitrary points and text it with "flow".

Background:

An and tag tag works best for it. However, I should not specify everywhere href . It should change the icon / location in the future. It depends on knowing the path of that image, which I do not always know-url-rewriting and on the same page due to different mapping, etc. I & lt; Span class = "icon" & Gt; & Lt; / Span & gt; and keep my icon as background-image Of course, this does not work because you can not have width on inline element. This is not working as a block (i.e. & lt; div & gt; ) element (for obvious reasons) and it does not work temporarily Display: Inline-block; Works in some browsers, but not all. Using the padding: The correct height and width for pad-out gives mixed results in different browsers with a transparent image for href And lt; Img & gt; Using a tag and a background-image works but looks like a hack.

Will this be the best way to accomplish this?

You can & lt; & lt; / Span & gt; & lt; / a & gt;

You can specify width / height at the elements exactly, so the CSS looks like this:

< Pre> a {position: relative; padding-right: 30px; / * width of your icon, assuming that you are in the scope of the text * /} A. Signon {display: block; / * good For the solution, but will not be required in all browsers * / Status: Absolute; Head: 0; Right: 0; width: 30px; height: 30px; background: url (your-icon.png) no-repeat 0 0;}

relative to & lt; a & By setting the status of gt , this creates a coordinate system for the all-in-one

If you do not know where the icon will appear, then "icon"> .

You can enter & lt; img & gt; with a transparent .gif as your source. tag.

  & lt; P & gt; Homepage & lt; Img src = "clear.gif" alt = "icon" square = "icon" /> Dollar valarium & lt; / P & gt;  

Then set the actual icon source using the CSS background property:

  img.icon {height: 30px; Width: 30px; Background: url (true-icon-src.png) no-repeat 0; / * If you want to adjust the vertical position of the image then use the following * Position: Relative; Top: 5px; }  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -