SlightlyClever
SlightlyClever

Reputation: 421

Add border to circle image

I've added a normal square image to my website and made it into a circle with border-radius and then have tried to add a circle border around it but it only seems to work on Chrome. Any suggestions on how I can fix this?

.face {
display: block;
margin: auto;
border-radius: 100%;
border: 5px solid #ff675b;}

Here is a screenshot of the issue: https://www.dropbox.com/s/4xy26phkjgz9te0/Screen%20Shot%202013-05-01%20at%2001.15.02.png

Upvotes: 17

Views: 99831

Answers (6)

ufukomer
ufukomer

Reputation: 1259

That is the way I use:

CSS:

.avatar {
    display: block;
    border-radius: 200px;
    box-sizing: border-box;
    background-color: #DDD;
    border: 5px solid #cfd8dc;
}

img {
    height: 200px;
    width: 200px
}

HTML:

<img class="avatar" src="..">

Upvotes: 9

Muhammad Hamza Nisar
Muhammad Hamza Nisar

Reputation: 601

Try this one it will be help for you.

.clip-circle {
      clip-path: circle(60px at center);
      /* OLD VALUE example: circle(245px, 140px, 50px); */
      /* Yep, even the new clip-path has deprecated stuff. */
    }
    .clip-ellipse {
      clip-path: ellipse(60px 40px at 75px 30px);
      /* OLD VALUE example: ellipse(245px, 80px, 75px, 30px); */
    }
    .clip-polygon {
      clip-path: polygon(5% 5%, 100% 0%, 100% 75%, 75% 75%, 75% 100%, 50% 75%, 0% 75%);
      /* Note that percentages work as well as px */
    }

Upvotes: 0

SlightlyClever
SlightlyClever

Reputation: 421

The HTML:

<div class="circleborder"><img class="face" src="img/face.jpeg" alt="face" width="130" height="130"></div>

CSS:

.face {
border-radius: 100%;}

.circleborder {
border: 5px solid #ff675b;
border-radius: 100%;
display: inline-block;}

Thanks for your help guys! I'm testing my solution as we speak and sofar it's worked on Chrome & Safari on my Mac and iPhone! :D

Upvotes: 2

Akusete
Akusete

Reputation: 10794

See this JsFiddle

http://jsfiddle.net/z3rLa/1/

.avatar {
    width:128px;
    margin: 10px;
    border:10px solid red;
    border-radius: 500px;
    -webkit-border-radius: 500px;
    -moz-border-radius: 500px;
}

Upvotes: 26

Manh Kh&#244;i Duong
Manh Kh&#244;i Duong

Reputation: 173

create a new class:

.circleborder {
width: 300px;
height: 300px;
border-radius: 150px;
-webkit-border-radius: 150px;
-moz-border-radius: 150px;
background: url(URL) no-repeat;
box-shadow: 0 0 8px rgba(0, 0, 0, .8);
-webkit-box-shadow: 0 0 8px rgba(0, 0, 0, .8);
-moz-box-shadow: 0 0 8px rgba(0, 0, 0, .8);
}

and this would be your html code:

<div class="circleborder"><img src="URL"/></div>

Upvotes: 5

Francisco Afonso
Francisco Afonso

Reputation: 247

http://www.css3.info/preview/rounded-border/

Border radius doesn't work the same way in every browser. You need different approaches.

Upvotes: 1

Related Questions