Answers for "set image through css"

CSS
0

insert image by css

div.mydiv:after {
  content: url(image.jpg); /*url of your image*/
}

or

div.mydiv {
   width:100px; /*width of your image*/
   height:100px; /*height of your image*/
   background-image:url('image.file');
}
Posted by: Guest on September-11-2020
1

change img src css

// You cannot do it with CSS alone
// You can with JS

element.style.src = "someImage.jpg";

// Or with jQuery
$('some-element').attr('src', 'someImage.jpg');
Posted by: Guest on April-03-2020

Browse Popular Code Answers by Language