The css code to use is
.yourclass:before {
background-image: url('your-url/your-image.jpg');
background-size: 20px 20px;
display: inline-block;
width: 20px;
height: 20px;
content:"";
}
a thoughtful use of digital
The css code to use is
.yourclass:before {
background-image: url('your-url/your-image.jpg');
background-size: 20px 20px;
display: inline-block;
width: 20px;
height: 20px;
content:"";
}
It may happen that an image you chose for a css after content is too big. Therefore you need to resize it.
The following code doesn’t work:
yourelement::after {
content: url(image.jpg);
width: 10px;
}
You should use this, instead
yourelement::after{
background-image: url(image);
background-size: 10px 20px;
display: inline-block;
width: 10px;
height: 20px;
content:"";
}
All browsers have this limitation: they not allow to show an svg with an external image embedded, such as
<image x="2" y="2" width="somewidth" height="someheight" xlink:href="myimage.jpg">
even though the image is in local.
For security reasons.
We managed to add an image map to the on-click expansible image.
This is the code:
<style type="text/css">
img[usemap] { zoom: 12%;}
img[usemap]:focus {zoom: 50%;}
</style>
<map name="mymap">
<area shape="rect" coords="1294,253,1420,434" title="mount" />
<area shape="rect" coords="1709,296,1835,477" title="tree" />
</map>
<img tabindex="0" src="path-to/myimage" usemap="#mymap" />
The problem is that to close the expansed image you must click either on a map area or outside the image.
We were looking for the simplest possible solution to enlarge an image on click, without javascript and with the least amount of code possible.
At first we found the pseudo-class focus as a solution: with this css code img:focus
and in html (inside the img tag) tabindex="0"
.
In this way, the image expanded on click, but to make it return to the initial size, it was necessary to click outside the enlarged image. As in the following example:
Therefore we had to add other code, so that we could return to the original, small, size, clicking inside the image. We had to use the input tag.
This is the result:
This is the code:
<style type="text/css">
input:checked + label > img {max-width: 200px; transform:scale(1.0); left: 0px;}
input {display: none;}
img {
max-width: 200px;
transition: all 1s;
transition:transform 0.25s ease;
}
img:focus {
max-width: none;
transform:scale(2.8);
position: relative;
left: 5%;
outline:0;
}
</style>
<p>This the result:</p>
<input type="checkbox" checked id="myimage" />
<label for="myimage">
<img tabindex="0" src="path-to-my-image/myimage.jpg" width="200px" />
</label>
We speak about this new feature in another article.
You can use a javascript, like this
<script type="text/javascript">
// img[style]').each(function(){
$el = $(this);
var style = $el.attr('style');
$el.attr('style','');
$el.parent().attr('style',style);
}); //Moves the inline styles
$("img").each(function(){
var title = this.alt;
$(this).after(''+ title +'');
}); //Adds the dynamic captions.
});
//]]>
</script>