آموزش تزئین متن(Text Decoration) در CSS

Ratings
(0)

در این مقاله، به آموزش ویژگی های زیر در CSS می پردازیم:

  1. text-decoration-line
  2. text-decoration-color
  3. text-decoration-style
  4. text-decoration-thickness
  5. text-decoration

اضافه کردن یک خط تزئینی(Decoration Line) به یک متن

از ویژگی text-decoration-line برای اضافه کردن خط تزئینی به یک متن استفاده می شود.

نکته: ما می توانیم بیش از یک مقدار، مانند overline یا underline استفاده کنیم تا خط بالایی، و خط زیرین را به یک متن اضافه کنیم.

مثال شماره 1

h1 {
  text-decoration-line: overline;
}

h2 {
  text-decoration-line: line-through;
}

h3 {
  text-decoration-line: underline;
}

p {
  text-decoration-line: overline underline;
}
امتحان کنید

 نکته: توصیه نمی شود برای یک متن که یک لینک نیست، underline ایجاد کنید. زیرا این کار باعث گیج شدن خواننده می شود. 

 


مشخص کردن یک رنگ برای خط تزئینی(Decoration Line)

از ویژگی text-decoration-color برای تنظیم رنگ خط تزئینی(decoration line) ستفاده می شود. منظور از خط تزئینی، خطی است که زیر یک لینک به هنگام رفتن ماوس روی آن، ایجاد می شود.

مثال شماره 2

h1 {
  text-decoration-line: overline;
  text-decoration-color: red;
}

h2 {
  text-decoration-line: line-through;
  text-decoration-color: blue;
}

h3 {
  text-decoration-line: underline;
  text-decoration-color: green;
}

p {
  text-decoration-line: overline underline;
  text-decoration-color: purple;
}
امتحان کنید

مشخص کردن یک استایل برای خط تزئینی(Decoration Line)

از ویژگی text-decoration-style برای تنظیم استایل برای خط تزئینی استفاده می شود.

مثال شماره 3

h1 {
  text-decoration-line: underline;
  text-decoration-style: solid;
}

h2 {
  text-decoration-line: underline;
  text-decoration-style: double;
}

h3 {
  text-decoration-line: underline;
  text-decoration-style: dotted;
}

p.ex1 {
  text-decoration-line: underline;
  text-decoration-style: dashed;
}

p.ex2 {
  text-decoration-line: underline;
  text-decoration-style: wavy;
}

p.ex3 {
  text-decoration-line: underline;
  text-decoration-color: red;
  text-decoration-style: wavy;
}
امتحان کنید

مشخص کردن ضخامت برای خط تزئینی

از ویژگی text-decoration-thickness برای تنظیم ضخامت خط تزئینی استفاده می شود.

مثال شماره 4

h1 {
  text-decoration-line: underline;
  text-decoration-thickness: auto;
}

h2 {
  text-decoration-line: underline;
  text-decoration-thickness: 5px;
}

h3 {
  text-decoration-line: underline;
  text-decoration-thickness: 25%;
}

p {
  text-decoration-line: underline;
  text-decoration-color: red;
  text-decoration-style: double;
  text-decoration-thickness: 5px;
}
امتحان کنید

ویژگی خلاصه شده ی خط تزئینی

ویژگی text-decoration یک ویژگی خلاصه شده برای تمام ویژگی های زیر است:

  • text-decoration-line (ضروری)
  • text-decoration-color (اختیاری)
  • text-decoration-style (اختیاری)
  • text-decoration-thickness (اختیاری)

مثال شماره 5

h1 {
  text-decoration: underline;
}

h2 {
  text-decoration: underline red;
}

h3 {
  text-decoration: underline red double;
}

p {
  text-decoration: underline red double 5px;
}
امتحان کنید

 یک نکته ی کوچک

تمام لینک ها در HTML به طور پیش فرض، یک زیرخط(underline) دارند. گاهی اوقات مشاهده می شود که برای لینک ها یک استایل تنظیم شده است که آندرلاین(زیرخط) نداشته باشند. از دستور text-decoration: none; برای حذف آندرلاین از لینک ها استفاده می شود. مانند مثال زیر:

مثال شماره 6

a {
  text-decoration: none;
}
امتحان کنید

 


تمام ویژگی های text-decoration در CSS

 

توضیح ویژگی
این ویژگی، تمام ویژگی های text-decoration را در یک دستور تنظیم می کند. text-decoration
این ویزگی، رنگ text-decoration را مشخص می کند. text-decoration-color
این ویژگی، نوع text decoration را مشخص می کند(مانند underline یا overline). text-decoration-line
این ویژگی، استایل text decoration را مشخص می کند(مانند solid یا dotted یا غیره). text-decoration-style
این ویژگی، ضخامت text decoration را مشخص می کند. text-decoration-thickness

 

  • بازدید: 176

نوشتن دیدگاه

لطفا نظرات خود را بیان کنید. به سوالات در سریع ترین زمان پاسخ داده خواهد شد.اما به نکات زیر توجه کنید:
1. سعی کنید نظرات شما مرتبط با مقاله ی مورد نظر باشد، در غیر این صورت پاسخ داده نخواهد شد.
2. سوالات خود را به صورت کوتاه بیان کنید و از پرسیدن چند سوال به طور همزمان خودداری کنید.
3. سوال خود را به طور واضح بیان کنید و از کلمات مبهم استفاده نکنید.

ارسال