حالت آفلاین — محتوا از حافظهٔ کش نمایش داده می‌شود
همهٔ تمرین‌ها

انتخاب عنصر داخل یک عنصر دیگه

تمرین آسان 1028 visibility link download flag

کد css بنویسید که تمام span هایی که بصورت مستقیم داخل div هستند رو انتخاب کند و رنگ متن آنها را به قرمز تغییر دهد

👨‍💻 24 ساعت قبل کاربر ناشناس این تمرین رو مشاهده کرد

پاسخ‌ها 13

index.html:

<!DOCTYPE html>
<html lang='fa'>
<head>
  <meta charset='utf-8'>
  <meta name='viewport' content='width=device-width, initial-scale=1'>
  <title>انتخاب عنصر داخل یک عنصر دیگه</title>
  <link rel='stylesheet' href='style.css'>
</head>
<body>
  <span>...</span>
  <div>
    <span>...</span>
  </div>
  <div>
    <p>.<span>.</span>.</p>
  </div>
</body>
</html>

style.css:

div > span{
    color: red;
}
<!DOCTYPE html>
<html dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>span تگ </title>
    <style>
        div > span {
            color: red; }
    </style>
</head>
<body>
    <div><span>This text will be red.</span>
        <div>         
         </div><span>This text will also be red.</span>
        </div>
         <span>This text will not be red.</span>
</body>
</html>
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>انتخاب عنصر داخل یک عنصر دیگه</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }

      body {
        display: flex;
        min-height: 100vh;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        gap: 5px;
        background-color: #f6f6f6;
      }

      div > span {
        color: red;
      }
    </style>
  </head>
  <body>
    <div><span>Hello</span></div>
    <span>Hello</span>
    <div>Hello</div>
  </body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <style>
    div>span{
        background-color: red;
    }
  </style>
</head>
<body>
  <div>
    <span>bg red</span>
  </div>
  <div>
    <p>no bg</p>
  </div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Training</title>
  <style>
   div > span{
    color: red;
    background-color: blanchedalmond;
    display: inline-block;
    width: 220px;
    padding: 10px;
    margin-top: 10px;
    border-radius: 20px;
    text-shadow: 0 0 8px black;
    box-shadow: 0 0 20px black;
   }
   div > span:hover{
    background-color: rgb(219, 211, 211);
    color: white;
   }
  </style>
</head>
<body>

  <div>
    mama mia...<span>heyyyy</span><br>
    <span>hey yooooo</span>
    <section>
      <p>hi babe!</p>
      <span>this is the end.</span>
    </section>
    <span>hold your breath and count to 10.</span>
    <p>from Adele</p>
  </div>

</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>انتخاب عنصر داخل یک عنصر دیگه</title>
    <style>
        div > span{
            color: red;
            font-size: 20px;
        }
    </style>
</head>
<body>
    <div>
        <span>a</span>
        <div>
            <span>b</span>
        </div>
        <span>c</span>
    </div>
</body>
</html>

ارسال جواب

جوابت را با Markdown بنویس و ثبت کن

×
بستن