0

I have two CSS classes:

.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius:10px;
}

.smaller-image {
width: 100px;
border-radius:30px;
}

Usage in HTML document:

<img class="thick-green-border smaller-image" src="https://s3.amazonaws.com/freecodecamp/relaxing-cat.jpg" alt="A cute orange cat lying on its back.">

When the image element is assigned both the classes, the rule for the style border-radius described in the class .smaller-image is taking effect, not the radius set inside thick-green-border class. That is the border-radius of the image is becoming 30px, not 10px.

Can anyone please tell me why? I have tried changing the order in which the classes are assigned to the image but the result is the same.

Yeasir Arafat Majumder
  • 1,222
  • 2
  • 15
  • 34

2 Answers2

0

Change the order of the classes in the CSS.

.thick-green-border {
  border-color: green;
  border-width: 10px;
  border-style: solid;
  border-radius: 10px;
}
.smaller-image {
  width: 100px;
  border-radius: 30px;
}
.smaller-image2 {
  width: 100px;
  border-radius: 30px;
}
.thick-green-border2 {
  border-color: green;
  border-width: 10px;
  border-style: solid;
  border-radius: 10px;
}
<img class="thick-green-border smaller-image" src="https://s3.amazonaws.com/freecodecamp/relaxing-cat.jpg" alt="A cute orange cat lying on its back.">

<img class="thick-green-border2 smaller-image2" src="https://s3.amazonaws.com/freecodecamp/relaxing-cat.jpg" alt="A cute orange cat lying on its back.">

They both have the same hierarchy level, so the latter one will be applied.

Jamie Barker
  • 8,145
  • 3
  • 29
  • 64
-1

Is this what you want?

.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius:10px;
display: inline-block;
}

.smaller-image {
width: 100px;
border-radius:30px;
}
<div class="thick-green-border">
<img class="smaller-image" src="https://s3.amazonaws.com/freecodecamp/relaxing-cat.jpg" alt="A cute orange cat lying on its back.">
  </div>
gabrielchl
  • 606
  • 9
  • 20