0

For example, I have class .book elementand it's 300px and i can't change it. And I have img with width: 160px, so how I can make content equal to the image width and not to .book-element?

.book-element {
  cursor: pointer;
  width: 300px;
}

.book-content img {
  height: 240px !important;
  width: 160px !important;
}

.book-content p {
  margin: 0;
  font-size: 16px;
  color: blue;
}

.book-content .title-book {
  margin-top: 8px;
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
}

.book-content .price {
  font-weight: bold;
  font-size: 18px;
}
<div class="book-element">
    <div class='book-content'>
        <img src='https://i.pinimg.com/474x/2c/0b/ee/2c0bee39cc1fff39ff1b09517e8962d6.jpg' alt="bookshop" />
        <p class="title-book">Looking for Alaska (special edition)</p>
        <p>J.Green</p>
        <p class="price">23.99$</p>
    </div>
</div>

enter image description here

Gover123
  • 69
  • 6
  • When you say you can’t change `book-element`, do you mean the HTML or the css? You don’t need to change book-element anyway, it’s `book-content` you need to change. Can you change the css for it? If so, you just need to set it’s width to the same as the image. But if you mean you can’t change *any* of the css, I’m not sure what you are looking to do? – FluffyKitten Jul 29 '20 at 11:35
  • @FluffyKitten I added image with example! I need to make width of title equal to image and not change the width of container. – Gover123 Jul 29 '20 at 11:45
  • 1
    You don’t need to change the width of the outer container of 300px... you can change the inner book-content class - that won’t affect your container. – FluffyKitten Jul 29 '20 at 11:49
  • 1
    @FluffyKitten now I understand how this question is stupid :D, thank you. If you want, you can leave an answer.. – Gover123 Jul 29 '20 at 12:07

0 Answers0