مشخصات مقاله
آموزش افکت قرار دادن متن روی تصویر در سایت
آموزش افکت قرار دادن متن روی تصویر در سایت
در این مقاله می آموزید که چطور با استفاده از CSS و Html اطراف تصویر ، متن قرار دهید.
قدم اول : کد HTML را اضافه کنید.
مثال :
Bottom LeftTop LeftTop RightBottom RightCentered
قدم دوم : کد CSS را اضافه کنید.
مثال :
/* Container holding the image and the text */ .container { position: relative; text-align: center; color: white; } /* Bottom left text */ .bottom-left { position: absolute; bottom: 8px; left: 16px; } /* Top left text */ .top-left { position: absolute; top: 8px; left: 16px; } /* Top right text */ .top-right { position: absolute; top: 8px; right: 16px; } /* Bottom right text */ .bottom-right { position: absolute; bottom: 8px; right: 16px; } /* Centered text */ .centered { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
نمونه مثال Position Text Over an Image:
<h2>متن روی تصویر</h2>
<p>نحوه قرار دادن متن روی تصویر</p><div class="container">
<img src="http://articles.tahlildadeh.com/image.axd?picture=img_snow_wide_1.jpg" alt="Snow" style="width:100%;">
<div class="bottom-left">پایین سمت چپ</div>
<div class="top-left">بالا سمت چپ</div>
<div class="top-right">بالا سمت راست</div>
<div class="bottom-right">سمت راست پایین</div>
<div class="centered">مرکز</div>
</div>
خروجی افکت Position Text Over an Image
