CSS ﺮﯾﻮﺼﺗ ﺖﯿﻓﺎﻔﺷ/ﺕﺭﻭﺪﮐ


فهرست مطالب

    نمایش فهرست مطالب


.ﺪﻨﮐ ﯽﻣ ﺺﺨﺸﻣ ﺍﺭ ﺮﺼﻨﻋ ﮏﯾ ﺖﯿﻓﺎﻔﺷ/ﺕﺭﻭﺪﮐ opacity


ﻑﺎﻔﺷ ﺮﯾﻮﺼﺗ

:ﺖﺳﺍ ﺮﺗ ﻑﺎﻔﺷ ،ﺪﺷﺎﺑ ﺮﺘﻤﮐ ﺭﺍﺪﻘﻣ ﻪﭼ ﺮﻫ .ﺩﺮﯿﮕﺑ 1.0 - 0.0 ﺯﺍ ﯼﺭﺍﺪﻘﻣ ﺪﻧﺍﻮﺗ ﯽﻣ

Forest

opacity 0.2

Forest

opacity 0.5

Forest

opacity 1
(default)

ﻝﺎﺜﻣ

img {
  opacity: 0.5;
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<head>
<style>
img {
  opacity: 0.5;
}
</style>
</head>
<body>

<h1>Image Transparency</h1>
<p>The opacity property specifies the transparency of an element. The lower the value, the more transparent:</p>

<p>Image with 50% opacity:</p>
<img src="img_forest.jpg" alt="Forest" width="170" height="100">

</body>
</html>



ﻑﺎﻔﺷ ﺭﻭﺎﻨﺷ ﺮﺛﺍ

:ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺱﻭﺎﻣ ﯽﯾﺎﺠﺑﺎﺟ ﻡﺎﮕﻨﻫ ﺭﺩ ﺕﺭﻭﺪﮐ ﺮﯿﯿﻐﺗ ﯼﺍﺮﺑ

Northern Lights
Mountains
Italy

ﻝﺎﺜﻣ

img {
  opacity: 0.5;
}
img:hover {
  opacity: 1.0;
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<head>
<style>
img {
  opacity: 0.5;
}

img:hover {
  opacity: 1.0;
}
</style>
</head>
<body>

<h1>Image Transparency</h1>
<p>The opacity property is often used together with the :hover selector to change the opacity on mouse-over:</p>
<img src="img_forest.jpg" alt="Forest" width="170" height="100">
<img src="img_mountains.jpg" alt="Mountains" width="170" height="100">
<img src="img_5terre.jpg" alt="Italy" width="170" height="100">

</body>
</html>


ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺢﯿﺿﻮﺗ ﻝﺎﺜﻣ

.ﺖﺳﺍ opacity:1; ﻦﯾﺍ ﯼﺍﺮﺑ CSS .ﺪﺷﺎﺒﻧ ﻑﺎﻔﺷ ﺮﯾﻮﺼ

.ﺩﻮﺷ ﯽﻣ ﻑﺎﻔﺷ ﻩﺭﺎﺑﻭﺩ ﺮﯾﻮﺼﺗ ،ﺩﻮﺷ ﯽﻣ ﺭﻭﺩ ﺮﯾﻮﺼﺗ ﺯﺍ ﺱﻭﺎﻣ ﺮﮕﻧﺎﺸﻧ ﻪﮐ ﯽﻣﺎﮕﻨﻫ

:ﺱﻮﮑﻌﻣ ﺭﻭﺎﻨﺷ ﺮﺛﺍ ﺯﺍ ﯽﻟﺎﺜﻣ

Northern Lights
Mountains
Italy

ﻝﺎﺜﻣ

img:hover {
  opacity: 0.5;
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<head>
<style>
img:hover {
  opacity: 0.5;
}
</style>
</head>
<body>

<h1>Image Transparency</h1>
<p>The opacity property is often used together with the :hover selector to change the opacity on mouse-over:</p>
<img src="img_forest.jpg" alt="Forest" width="170" height="100">
<img src="img_mountains.jpg" alt="Mountains" width="170" height="100">
<img src="img_5terre.jpg" alt="Italy" width="170" height="100">

</body>
</html>




ﻑﺎﻔﺷ ﻪﺒﻌﺟ

ﻥﺁ ﺪﻧﺯﺮﻓ ﺮﺻﺎﻨﻋ ﻪﻤﻫ ،ﺮﺼﻨﻋ ﮏﯾ ﻪﻨﯿﻣﺯﺲﭘ ﻪﺑ ﺖﯿﻓﺎﻔﺷ ﻥﺩﻭﺰﻓﺍ ﯼﺍﺮﺑ

opacity 1

opacity 0.6

opacity 0.3

opacity 0.1

ﻝﺎﺜﻣ

div {
  opacity: 0.3;
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<head>
<style>
div {
  background-color: #04AA6D;
  padding: 10px;
}

div.first {
  opacity: 0.1;
}

div.second {
  opacity: 0.3;
}

div.third {
  opacity: 0.6;
}
</style>
</head>
<body>

<h1>Transparent Box</h1>
<p>When using the opacity property to add transparency to the background of an element, all of its child elements become transparent as well. This can make the text inside a fully transparent element hard to read:</p>

<div class="first"><p>opacity 0.1</p></div>
<div class="second"><p>opacity 0.3</p></div>
<div class="third"><p>opacity 0.6</p></div>
<div><p>opacity 1 (default)</p></div>

</body>
</html>



RGBA ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﺎﺑ ﺖﯿﻓﺎﻔﺷ

.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ RGBA ﮓﻧﺭ ﺮﯾﺩﺎﻘﻣ ﺯﺍ ،ﻻﺎﺑ ﻝﺎﺜﻣ ﺪﻨﻧﺎﻣ ،ﺪﯿﻨﮐ ﻝﺎﻤﻋﺍ

100% opacity

60% opacity

30% opacity

10% opacity

،RGB ﺮﺑ ﻩﻭﻼﻋ .ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﮓﻧﺭ ﺭﺍﺪﻘﻣ ﻥﺍﻮﻨﻋ ﻪﺑ RGB ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﻪﮐ ﺪﯿﺘﻓﺮﮔ ﺩﺎﯾ ﺎ

ﺍﺭ .ﺩﻮﺷﯽﻣ ﺺﺨﺸﻣ (ﺎﻔﻟﺁ ،ﯽﺑﺁ ،ﺰﺒﺳ ،ﺰﻣﺮﻗ) rgba :ﺎﺑ RGBA ﮓﻧﺭ ﺭﺍﺪﻘﻣ ﮏﯾ

ﻪﺘﮑﻧ: ﮓﻧﺭ ﺶﺨﺑ ﺭﺩﯼﺎﻫ CSS ﮓﻧﺭ ﻩﺭﺎﺑﺭﺩ ﺎﻣﯼﺎﻫ RGBA ﺩﺮﮐ ﺪ

ﻝﺎﺜﻣ

div {
  background: rgba(76, 175, 80, 0.3) /* Green background with 30% 
opacity */
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<head>
<style>
div {
  background: rgb(4, 170, 109);
  padding: 10px;
}

div.first {
  background: rgba(4, 170, 109, 0.1);
}

div.second {
  background: rgba(4, 170, 109, 0.3);
}

div.third {
  background: rgba(4, 170, 109, 0.6);
}
</style>
</head>
<body>

<h1>Transparent Box</h1>
<p>With opacity:</p>
<div style="opacity:0.1;"><p>10% opacity</p></div>
<div style="opacity:0.3;"><p>30% opacity</p></div>
<div style="opacity:0.6;"><p>60% opacity</p></div>
<div><p>opacity 1</p></div>

<p>With RGBA color values:</p>
<div class="first"><p>10% opacity</p></div>
<div class="second"><p>30% opacity</p></div>
<div class="third"><p>60% opacity</p></div>
<div><p>default</p></div>

<p>Notice how the text gets transparent as well as the background color when using the opacity property.</p>

</body>
</html>



ﻑﺎﻔﺷ ﻪﺒﻌﺟ ﺭﺩ ﻦﺘﻣ

This is some text that is placed in the transparent box.

ﻝﺎﺜﻣ

<html>
<head>
<style>
div.background {
    background: url(klematis.jpg) repeat;
    border: 2px solid black;
}

div.transbox {
    margin: 30px;
    background-color: #ffffff;
    border: 1px solid black;
  opacity: 0.6;
}

div.transbox p {
  margin: 5%;
  font-weight: bold;
    color: #000000;
}
</style>
</head>
<body>

<div class="background">
  <div class="transbox">
    <p>This is some text that is placed in the transparent box.</p>
  </div>
</div>

</body>
</html>

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<head>
<style>
div.background {
  background: url(klematis.jpg) repeat;
  border: 2px solid black;
}

div.transbox {
  margin: 30px;
  background-color: #ffffff;
  border: 1px solid black;
  opacity: 0.6;
}

div.transbox p {
  margin: 5%;
  font-weight: bold;
  color: #000000;
}
</style>
</head>
<body>

<div class="background">
  <div class="transbox">
    <p>This is some text that is placed in the transparent box.</p>
  </div>
</div>

</body>
</html>


ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺢﯿﺿﻮﺗ ﻝﺎﺜﻣ

.ﻢﯿﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﻪﯿﺷﺎﺣ ﮏﯾ ﻭ ﻪﻨﯿﻣﺯ ﺲﭘ ﺮﯾﻮﺼﺗ ﮏﯾ ﺎﺑ div> (class="background")> ﺮﺼﻨﻋ

.ﻢﯿﻨﮐ ﯽﻣ ﺩﺎﺠﯾﺍ ﻝﻭﺍ <div> ﻞﺧﺍﺩ ﺭﺩ ("class="transbox) ﺮﮕﯾﺩ <div> ﮏﯾ ﺲﭙﺳ

ﺍﺭ

ﻑﺎﻔﺷ ﻞﺧﺍﺩ


تمامی حقوق محفوظ است. © BasicIT.org • 2023-2024