کانال بله, جهت پشتیبانی و اطلاع رسانی کانال بله, جهت پشتیبانی و اطلاع رسانی
عضویت
بستن تبلیغات
دوره طراحی سایت حرفه‌ای با پروژه واقعی!

دوره جامع و پروژه‌محور طراحی وب با تمرکز روی JavaScript، Ajax و API! با طراحی ریسپانسیو و پروژه‌های حرفه‌ای مثل دیجی‌کالا و شمرون کباب مهارتت رو حرفه‌ای کن!

مشاهده بیشتر
آموزش تخصصی فرانت‌اند با پروژه عملی

این دوره شما رو از مفاهیم پایه تا مباحث پیشرفته مثل JavaScript، React و Next.js پیش می‌بره. با آموزش پروژه‌محور، یک فروشگاه اینترنتی کامل طراحی می‌کنید و برای ورود به بازار کار آماده می‌شید!

مشاهده بیشتر

ایجاد منو ریسپانسیو در طراحی وب سایت

در این مقاله می آموزیم که چطور یک نوار منوی بالایی واکنش گرا با استفاده از کد CSS و جاوا اسکریپت را ایجاد کنیم.



ساخت نوار منو بالایی در وب سایت


قدم اول : کد HTML را اضافه کنید.
مثال :








قدم دوم :   کد CSS را اضافه کنید.
مثال :

/* Add a black background color to the top navigation */
.topnav {
background-color: #333;
overflow: hidden;
}

/* Style the links inside the navigation bar */
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}

/* Change the color of links on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
}

/* Add an active class to highlight the current page */
.topnav a.active {
background-color: #4CAF50;
color: white;
}

/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
display: none;
}

قدم سوم :   دستورات Media Query را اضافه کنید.
مثال :


/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */
@ media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}

/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */
@ media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive a.icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}

قدم چهارم :   کد جاوا اسکریپت زیر را اضافه کنید تا منو ریسپانسیو بصورت کامل برای شما ساخته شود.


مثال ساخت منو ریسپانسیو :

function myFunction() {
  var x = document.getElementById("myTopnav");
  if (x.className === "topnav") {
    x.className += " responsive";
  } else {
    x.className = "topnav";
  }
}

امتحان کنید

ساخت منو ریسپانسیو در وب سایت
1404/02/02 5357 1026
رمز عبور : tahlildadeh.com یا www.tahlildadeh.com
نظرات شما

نظرات خود را ثبت کنید...