تسمح لك خاصية التحويل transform في CSS بإدارة وتغيير إحداثيات وأبعاد العناصر وما إلى ذلك كما سنتعرف في هذه الوثيقة.
ويتم ذلك عن طريق تعديل الإحداثيات لنموذج التنسيق المرئي للـ CSS.
يتم تخزين المصدر لهذا المثال التفاعلي في مستودع GitHub. إذا كنت ترغب في المساهمة في مشروع الأمثلة التفاعلية ، فيرجى استنساخ https://github.com/mdn/interactive-examples وإرسال طلب سحب.
إذا كانت الخاصية لها قيمة مختلفة عن none ، فسيتم إنشاء سياق تجميع. في هذه الحالة ، سيكون الكائن بمثابة كتلة تحتوي على position: fixed العناصر التي تحتوي عليها.
بناء الجملة
/* قيم رئيسية */ transform: none; /* قيم وضيفية */ transform: matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); transform: translate(12px, 50%); transform: translateX(2em); transform: translateY(3in); transform: scale(2, 0.5); transform: scaleX(2); transform: scaleY(0.5); transform: rotate(0.5turn); transform: skew(30deg, 20deg); transform: skewX(30deg); transform: skewY(1.07rad); transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: translate3d(12px, 50%, 3em); transform: translateZ(2px); transform: scale3d(2.5, 1.2, 0.3); transform: scaleZ(0.3); transform: rotate3d(1, 2.0, 3.0, 10deg); transform: rotateX(10deg); transform: rotateY(10deg); transform: rotateZ(10deg); transform: perspective(17px); /* قيم وضيفية متعددة */ transform: translateX(10px) rotate(10deg) translateY(5px); /* قيمة عامة */ transform: inherit; transform: initial; transform: unset;
التحويل يمكن أن يحدد بقيمة واحدة أو أكثر من وضيفة.
القيم
<transform-function>- يمكنك استعمال وظيفة واحد أو أكثر من وظائف تحويل CSS ليتم تطبيقها. يتم تطبيق التحويلات المركبة بشكل فعال بالترتيب من اليسار إلى اليمين.
noneيحدد بعدم تحديد أي تحويل.
البنية
Syntax not found in DB!
أمثلة
HTML
<div>عنصر التحويل</div>
CSS
div {
border: solid red;
transform: translate(30px, 20px) rotate(20deg);
width: 140px;
height: 60px;
}
النتيجة
Please see Using CSS transforms and <transform-function> for more examples.
الميزات
| الميزة | الحالة | التعليق |
|---|---|---|
| CSS Transforms Level 2 The definition of 'transform' in that specification. |
Editor's Draft | Adds 3D transform functions. |
| CSS Transforms Level 1 The definition of 'transform' in that specification. |
Working Draft | Initial definition. |
Value not found in DB!
توافق المتصفح
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
transform | Chrome
Full support
36
| Edge
Full support
12
| Firefox
Full support
16
| IE
Full support
10
| Opera
Full support
23
| Safari
Full support
9
| WebView Android
Full support
37
| Chrome Android
Full support
36
| Firefox Android
Full support
16
| Opera Android
Full support
24
| Safari iOS
Full support
9
| Samsung Internet Android
Full support
3.0
|
| 3D support | Chrome Full support 12 | Edge Full support 12 | Firefox Full support 16 | IE
Full support
10
| Opera Full support 15 | Safari Full support 4 | WebView Android
Full support
3
| Chrome Android Full support 18 | Firefox Android Full support 16 | Opera Android Full support 14 | Safari iOS Full support 3.2 | Samsung Internet Android Full support 1.0 |
Legend
- Full support
- Full support
- See implementation notes.
- See implementation notes.
- User must explicitly enable this feature.
- User must explicitly enable this feature.
- Requires a vendor prefix or different name for use.
- Requires a vendor prefix or different name for use.
قد يفيدك
- استعمال CSS transforms
<transform-function>نوع البيانات- إظافة التحول إلى jQuery