البرنامج التعليمي Bootstrap 3

BS HOME ابدأ BS BS Grid Basic بكالوريوس الطباعة جداول BS صور بكالوريوس BS Jumbotron بي إس ويلز تنبيهات BS أزرار BS مجموعات زر BS BS Glyphicons شارات / ملصقات BS أشرطة التقدم BS ترقيم الصفحات BS بكالوريوس بيجر مجموعات قائمة BS لوحات BS القوائم المنسدلة BS انهيار BS علامات التبويب / حبوب BS Navbar نماذج بكالوريوس مدخلات BS مدخلات BS 2 تحجيم المدخلات BS كائنات BS Media BS كاروسيل مشروط BS تلميح BS Tooltip BS Popover BS Scrollspy BS اللصقة مرشحات BS

شبكات التمهيد

نظام BS Grid BS مكدس / أفقي BS Grid Small BS شبكة متوسطة BS شبكة كبيرة أمثلة على شبكة BS

ثيمات Bootstrap

قوالب بكالوريوس موضوع BS "ببساطة أنا" موضوع BS "شركة" موضوع BS "الفرقة"

أمثلة التمهيد

أمثلة بكالوريوس اختبار BS تمارين البكالوريوس شهادة بكالوريوس

Bootstrap CSS المرجع

CSS جميع الفئات طباعة CSS أزرار CSS نماذج CSS مساعدي CSS صور CSS جداول CSS القوائم المنسدلة CSS ملاحق CSS الحروف الرسومية

Bootstrap JS المرجع

شبيبة الملحقة تنبيه JS زر JS JS Carousel طي JS JS المنسدلة شبيبة مشروط شبيبة بوبوفر شبيبة Scrollspy علامة التبويب JS JS Tooltip


Bootstrap JS Affix


JS Affix (affix.js)

يتيح المكون الإضافي Affix لعنصر أن يتم إلصاقه (مقفلًا) في منطقة على الصفحة. غالبًا ما يستخدم هذا مع قوائم التنقل أو أزرار الرموز الاجتماعية ، لجعلها "ثابتة" في منطقة معينة أثناء التمرير لأعلى ولأسفل الصفحة.

يقوم المكون الإضافي بتبديل هذا السلوك وإيقاف تشغيله (يغير قيمة موضع CSS من ثابت إلى ثابت) ، اعتمادًا على موضع التمرير.

يبدل الملحق الإضافي بين ثلاث فئات: .affixو .affix-topو و .affix-bottom. كل فئة تمثل دولة معينة. يجب عليك إضافة خصائص CSS للتعامل مع المواضع الفعلية ، باستثناء position:fixed في .affixالفئة.

لمزيد من المعلومات ، اقرأ برنامجنا التعليمي Bootstrap Affix .

نصيحة: غالبًا ما يتم استخدام المكون الإضافي Affix مع المكون الإضافي Scrollspy .


عبر data- * السمات

أضف data-spy="affix"إلى العنصر الذي تريد التجسس عليه ، والسمة لحساب موضع التمرير.data-offset-top|bottom="number"

مثال

<ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="205">

عبر JavaScript

التمكين يدويًا باستخدام:

مثال

$('.nav').affix({offset: {top: 150} });


خيارات اللصق

يمكن تمرير الخيارات عبر سمات البيانات أو JavaScript. لسمات البيانات ، قم بإلحاق اسم الخيار بالبيانات- ، كما في data-offset = "".

Name Type Default Description
offset number | object | function 10 Specifies the number of pixels to offset from screen when calculating position of scroll. When using a single number, the offset is added to both top and bottom directions. If you only want to control the top or the bottom, use an object, like offset: {top:25}

For multiple offsets, use offset: {top:25, bottom:50}

Tip: Use a function to dynamically provide an offset (can be useful for responsive designs)
target selector | node | element the window object Specifies the target element of the affix

الأحداث الملصقة

يسرد الجدول التالي جميع الأحداث الملحقة المتاحة.

Event Description Try it
affix.bs.affix Occurs before fixed positioning is added to the element (e.g, when the .affix-top class is about to be replaced with the .affix class)
affixed.bs.affix Occurs after fixed positioning is added to the element (e.g., after the .affix-top class is replaced with the .affix class)
affix-top.bs.affix Occurs before the top element returns to its original (non-fixed) position (e.g., the .affix class is about to be replaced with .affix-top)
affixed-top.bs.affix Occurs after the top element returns to its original (non-fixed) position (e.g., the .affix class has been replaced with .affix-top)
affix-bottom.bs.affix Occurs before the bottom element returns to its original (non-fixed) position (e.g., the .affix class is about to be replaced with .affix-bottom)
affixed-bottom.bs.affix Occurs after the bottom element returns to its original (non-fixed) position (e.g., the .affix class has been replaced with .affix-bottom)

مزيد من الأمثلة

الملصقة نافبار

قم بإنشاء قائمة تنقل أفقية مثبتة:

مثال

<nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="197">

استخدام jQuery لإلصاق شريط التنقل تلقائيًا

استخدم طريقة externalHeight () لـ jQuery لإلصاق شريط التنقل بعد تمرير المستخدم لعنصر محدد (<header>):

مثال

$(".navbar").affix({offset: {top: $("header").outerHeight(true)} });

Scrollspy & Affix

استخدام ملحق Affix مع البرنامج المساعد Scrollspy :

قائمة أفقية (Navbar)

<body data-spy="scroll" data-target=".navbar" data-offset="50">

<nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="197">
...
</nav>

</body>

القائمة العمودية (Sidenav)

<body data-spy="scroll" data-target="#myScrollspy" data-offset="15">

<nav class="col-sm-3" id="myScrollspy">
  <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="205">
  ...
</nav>

</body>

نافبار متحرك على اللاحقه

استخدم CSS لمعالجة فئات .affix المختلفة:

مثال - تغيير لون الخلفية والمساحة المتروكة لشريط التنقل عند التمرير

.affix {
  top: 0;
  width: 100%;
  -webkit-transition: all .5s ease-in-out;
  transition: all .5s ease-in-out;
  background-color: #F44336;
  border-color: #F44336;
}

.affix a {
  color: #fff !important;
  padding: 15px !important;
  -webkit-transition: all .5s ease-in-out;
  transition: all .5s ease-in-out;
}

.affix-top a {
  padding: 25px !important;
}

مثال - التمرير في شريط التنقل

.affix {
  top: 0;
  width: 100%;
  -webkit-transition: all .5s ease-in-out;
  transition: all .5s ease-in-out;
}

.affix-top {
  position: static;
  top: -35px;
}