[!NOTE] تم إيقاف postcss-cssnext رسميا لصالح postcss-preset-env. تعد ورقة المساعدة هذه دليلا أرشيفيا للمشاريع التي تستخدم صيغ cssnext القديمة.
خصائص CSS المخصصة (المتغيرات)
:root {
--primary-color: #3b82f6;
--spacing-base: 1rem;
}
.button {
background: var(--primary-color);
padding: var(--spacing-base);
}
المحددات المخصصة والتداخل (Nesting)
المحددات المخصصة (Custom Selectors)
@custom-selector :--heading h1, h2, h3, h4, h5, h6;
:--heading {
margin-top: 0;
font-weight: 700;
}
تداخل المحددات (CSS Nesting)
.card {
padding: 1rem;
& .title {
font-size: 1.25rem;
}
&:hover {
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
}
استعلامات الوسائط المخصصة (Custom Media Queries)
@custom-media --small-viewport (max-width: 30em);
@custom-media --large-viewport (min-width: 60em);
@media (--small-viewport) {
body {
font-size: 14px;
}
}
دوال الألوان الوظيفية (Color Functions)
a {
/* تعديل الشفافية النسبية */
color: color(var(--primary-color) alpha(-20%));
color: color(red tint(20%)); /* تفتيح اللون */
color: color(blue shade(30%)); /* تعتيم اللون */
/* رمادي بقيمة ثابتة */
background: gray(50);
/* رمادي بنسبة إضاءة مئوية */
background: gray(80%);
}