Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a rounded rectangle shape Css?

I'm trying to design a profile image shape just like this

correct image design

but my code given me the following design

my design

I'm worried about the white space inside the border and the shape here is code

.doctor-profile-photo {
  width: 210px;
  height: 210px;
  border-radius: 60px/140px;
  border: 5px solid #000;
  box-shadow: 0px 2px 5px #ccc;
}
.doctor-profile-photo img {
  width: 100%;
  height: 100%;
  border-radius: 60px/140px;
}
<div class="doctor-profile-photo">
  <img src="http://weknowyourdreams.com/images/bird/bird-09.jpg" alt="">
</div>
like image 293
Kashif Latif Avatar asked Jan 09 '16 10:01

Kashif Latif


People also ask

How do you make a rectangle rounded in CSS?

just add -webkit-border-radius: 15px; in css. It will work.

How do you make a shape round in CSS?

To create a circle we can set the border-radius on the element. This will create curved corners on the element. If we set it to 50% it will create a circle. If you set a different width and height we will get an oval instead.

What CSS property creates rounded corners on a box?

The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, or two radii to make elliptical corners.

How do you make a DIV box rounded?

With CSS add the code: border-radius: 10px . I use 10px for example, but you can experiment with however amount of pixels you like.


1 Answers

This gives pretty similar output to what you want. Try tweaking the values of border-radius and height-width to achieve exactly what you want.

<style>
 #pic { 
    position: relative;     
    width: 130px; 
    height: 150px; 
    margin: 20px 0; 
    background: red; 
    border-radius: 50% / 10%; 
    color: white; 
    text-align: center; 
    text-indent: .1em;
 } 
 #pic:before { 
    content: ''; 
    position: absolute; 
    top: 10%; 
    bottom: 10%; 
    right: -5%; 
    left: -5%; 
    background: inherit; 
    border-radius: 5% / 50%; 
 } 
</style>
<div id="pic"></div>

Here's a useful link : https://css-tricks.com/examples/ShapesOfCSS/

like image 96
Nijraj Gelani Avatar answered Sep 19 '22 18:09

Nijraj Gelani