Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to put img inside circle in html and css?

Tags:

html

css

Image should be inside the circle and circle should have white background.

and Image size should be less than the circle and in center.

I try this:

.icon i {
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  font-size: 25px;
  text-align: center;
  margin-right: 10px;
  padding-top: 15%;
}
<li><a href="#"><i class="icon" style="background: red;"> <img src="http://www.pngdot.com/wp-content/uploads/2015/11/Free_Arrow_Png_01.png"  style="width:50px;height:45px;"></i></a></li>
like image 378
Shubham Batra Avatar asked Dec 05 '25 10:12

Shubham Batra


2 Answers

If I understand you correctly can use border-radius for the circle.

body {
  background:#000;  
}

* {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

i {
  background: white;
  border-radius: 20px;
  font-size: 25px;
  text-align: center;
  margin-right: 10px;
  border-radius:50%;
  display:inline-block;
  padding:10px;
}

img {
  display:block;
}
<i><img src="https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/410.svg" width="30" /></i>
like image 180
Mosh Feu Avatar answered Dec 07 '25 23:12

Mosh Feu


You can do this:

CSS

body{
  background: #f1f1f1;
}

figure{
    display:block;
    width:50px;
    height: 50px;
    border-radius: 50px;
    font-size: 25px;
    text-align: center;
    margin-right: 10px;
    background: #fff;
    line-height: 1.7em;
}

figure img{
   display:inline-block;
   width: 30px;
   height: auto;
}

HTML

<li>
  <a href="#">
    <figure>
      <img src="http://www.pngdot.com/wp-content/uploads/2015/11/Free_Arrow_Png_01.png" alt="image">
    </figure>
  </a>
</li>

DEMO HERE

like image 41
Luís P. A. Avatar answered Dec 08 '25 00:12

Luís P. A.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!