10
Q:

how to add an image in css

.element {
  background-image: url("imageFile.png");
}
2
background-image: url("imageFile.png");
2
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');
}
0

    <img src="smiley.gif" alt="Smiley face" width="42" height="42" style="vertical-align:bottom">

    <img src="smiley.gif" alt="Smiley face" width="42" height="42" style="vertical-align:middle">

    <img src="smiley.gif" alt="Smiley face" width="42" height="42" style="vertical-align:top">

    <img src="smiley.gif" alt="Smiley face" width="42" height="42" style="float:right">

    <img src="smiley.gif" alt="Smiley face" width="42" height="42" style="float:left"> 
0
.parent {
  position: relative;
  top: 0;
  left: 0;
}
.image1 {
  position: relative;
  top: 0;
  left: 0;
  border: 1px red solid;
}
.image2 {
  position: absolute;
  top: 30px;
  left: 30px;
  border: 1px green solid;
}
0

New to Communities?

Join the community