I have an unordered list of links and each link has a unique id.
I'm using that id with the :before
selector to place
the associated website's favicon before the link (using the content property).
One of these icons is twice the size of the others.
Is there any way to change the size of this icon using CSS?
If the answer is no, is there any way to do this other than editing the image?
Visual reference:
Here is what I tried (and it doesn't seem to work):
#geog:before { content: url("icons/geogebra.ico") " "; height: 50%; width: 50%; }
We can resize the image by specifying the width and height of an image. A common solution is to use the max-width: 100%; and height: auto; so that large images do not exceed the width of their container. The max-width and max-height properties of CSS works better, but they are not supported in many browsers.
The resize property defines if (and how) an element is resizable by the user. Note: The resize property does not apply to inline elements or to block elements where overflow="visible". So, make sure that overflow is set to "scroll", "auto", or "hidden".
The max-width property in CSS is used to create resize image property. The resize property will not work if width and height of image defined in the HTML. Width can also be used instead of max-width if desired. The key is to use height:auto to override any height=”…” attribute already present on the image.
I've run into the same problem before. Try this:
#geog:before { display: inline-block; width: 16px; height: 16px; margin-right: 5px; content: ""; background: url("icons/geogebra.ico") no-repeat 0 0; background-size: 100%; }
I'm sure you'll have to tweak those values, but that worked for me. Of course, this won't work if you can't set it as a background image for some reason. Best of luck to you!
I believe you are looking for the zoom
property. Check this jsfiddle
Also you can add spacing with margin-right
between the icon and the content of the element.
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