كيف - قطع النص
تعرف على كيفية إنشاء نص مقتطع / خروج سريع الاستجابة باستخدام CSS.
النص المقطوع (أو النص المطلق) هو نص شفاف يظهر مقطوعًا أعلى صورة الخلفية:
طبيعة سجية
ملاحظة: هذا المثال لا يعمل في Internet Explorer أو Edge.
كيفية إنشاء نص مقطوع
الخطوة 1) أضف HTML:
مثال
<div class="image-container">
<div class="text">NATURE</div>
</div>
الخطوة 2) أضف CSS:
تتيح mix-blend-mode
الخاصية إمكانية إضافة النص المقطوع إلى الصورة. ومع ذلك ، فهو غير مدعوم في IE أو Edge:
مثال
.image-container {
background-image: url("img_nature.jpg");
/* The image used - important! */
background-size: cover;
position: relative; /* Needed to position
the cutout text in the middle of the image */
height: 300px; /* Some
height */
}
.text {
background-color: white;
color: black;
font-size: 10vw;
/* Responsive font size */
font-weight: bold;
margin: 0 auto; /* Center the text container */
padding: 10px;
width: 50%;
text-align: center; /* Center text */
position: absolute; /* Position text */
top: 50%; /* Position text in the middle */
left: 50%; /* Position
text in the middle */
transform: translate(-50%, -50%); /* Position text in the middle */
mix-blend-mode: screen;
/* This makes the cutout text possible */
}
إذا كنت تريد نص حاوية سوداء ، فغيّر وضع المزج إلى "مضاعفة" ولون الخلفية إلى الأسود ، واللون إلى الأبيض:
مثال
.text {
background-color: black;
color: white;
mix-blend-mode:
multiply;
....
}