Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

select a className that is in div className CSS

Hi i have two different html divs that contain the same price class ="uvp uvp-price".

 <div class="product-detail-price-container">
    <meta itemprop="price" content="119.8">                                                             
    <p class="uvp uvp-price">UVP: 50,00&nbsp;€</p>
    <p class="twp-product-detail-price" style="margin-top: -52px;">EK: 29.95 €</p>
 </div>

and

<div class="product-price-info">
    <div class="tw-price-unit"></div>
    <p class="uvp uvp-price">UVP: 50,00&nbsp;€</p>
 </div>

now i only want to give the first uvp uvp-price class that is inside the div class product-detail-price-container a padding-top: 15px;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

i tried this but doesnt work.

.product-detail-price-container:has(.uvp-price) {
  padding-top: 15px;
}

what am i doing wrong ? thanks

>Solution :

You can use > selector to get a class inside something:

.product-detail-price-container > .uvp.uvp-price
.product-detail-price-container > .uvp.uvp-price {
  border: 1px solid red;
}
<div class="product-detail-price-container">
    <meta itemprop="price" content="119.8">                                                             
    <p class="uvp uvp-price">UVP: 50,00&nbsp;€</p>
    <p class="twp-product-detail-price" style="margin-top: -52px;">EK: 29.95 €</p>
 </div>


<div class="product-price-info">
    <div class="tw-price-unit"></div>
    <p class="uvp uvp-price">UVP: 50,00&nbsp;€</p>
 </div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading