ফিক্সেড সাইড বার কিভাবে করবেন?
সাইড বার একটি বহুল ব্যবহৃত একটি প্লাগিন। অনেক ওয়েবসাইটে সাইড বার থাকে। কোন কোন ওয়েবসাইটের বাঁ পাশে আর কোন কোন ওয়েবসাইটে ডান পাশে এবং কিছু ওয়েবসাইটের দুই পাশেই সাইডবার থাকে। আমি এখানে বাঁ পাশে একটি ফিক্সেড সাইডবার নিয়ে কাজ করেছি। তবে, এরকম সাইডবারে ছোট্ট একটি সমস্যা হয়। ওয়েব পেজকে যখন ছোট্ট টেবলেট অথবা মোবাইল ভিউতে নেওয়া হয়, তখন সাইডবারের কারণে প্রধান কন্টেন্ট গুলোর জায়গা ছোট হয়ে যায়। আমি এখানে, এই সমস্যার ছোট একটি সমাধান দিয়েছি। ওয়েবসাইট যখন মোবাইল ভিউতে প্রদর্শিত হবে, তখন সাইডবার লুকানো অবস্থায় চলে যাবে। সাথে উপরে একটি বার শো হবে, যাতে ক্লিক করলে সাইডবার টুগল হবে। অনেকটা আমার এই ওয়েবসাইটের বাঁ পাশের সাইডবারের মত। তবে জাভাস্ক্রিপ্টের টিউটোরিয়ালে এটাকে খানিক'টা ভিন্ন ভাবে দেখাব ইনশা-আল্লাহ। আরো বিস্তারিত জানতে ভিডিও টিউটোরিয়াল'টি দেখুন।
বিস্তারিত ভিডিও সহ দেখুন
কোড উদাহরণ
<!DOCTYPE html>
<html>
<head>
<title>Fixed Sidebar Example</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Roboto"
rel="stylesheet">
<link rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.7.0/css/all.css">
<style>
body {
font: normal 1.125em/1.5 'Roboto', sans-serif;
}
*{padding:0;margin:0;}
.sidebar{
height:100%;
width:200px;
position:fixed;
background-color:#48A671;
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
-ms-transition: all 0.4s ease;
transition: all 0.4s ease;
z-index:1;
}
.sidebar a{
text-decoration:none;
display:block;
height:50px;
line-height:50px;
font-size:18px;
color:#ddd;
padding:0 12px;
border-bottom:1px solid #398459;
}
.sidebar a .fa, .sidebar a .fas{
margin-right:10px;
}
.sidebar a:hover{
color:#fff;
background-color:#398459;
}
.main{
background-color:#f0f0f0;
margin-left:200px;
padding:10px;
}
.main p{
text-align:justify;
margin-bottom:20px;
}
.mobile-view{
height:40px;
width:100%;
background-color:#48A671;
border-bottom:1px solid #398459;
position:fixed;
display:none;
z-index:99;
}
.fa-bars{
color:#ddd;
font-size:22px;
line-height:40px;
height:40px;
width:40px;
text-align:center;
}
.fa-bars:hover{
background-color:#398459;
color:#fff;
cursor:pointer;
}
@media (max-width: 533px){
.sidebar{
left:-201px;
top:41px;
}
.main{
margin-left:0;
padding-top:50px;
}
.mobile-view{display:block;}
}
</style>
</head>
<body>
<div class="container">
<div class="mobile-view">
<li onclick="toggle()" class="fa fa-bars"></li>
</div>
<div class="sidebar" id="sidebar">
<a href="#"><i class="fa fa-home"></i> HOME</a>
<a href="#"><i class="fa fa-info"></i> ABOUT US</a>
<a href="#"><i class="fas fa-address-book"></i> CONTACT US</a>
<a href="#"><i class="fas fa-cogs"></i> SERVICES</a>
<a href="#"><i class="fa fa-map-marker"></i> LOCATION</a>
</div>
<div class="main">
<h2> Main Section</h2>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
</div>
<script>
function toggle(){
var Sidebar = document.getElementById("sidebar");
if (Sidebar.style.left =='0px'){
Sidebar.style.left = '-201px';
return;
}
Sidebar.style.left ='0px';
}
</script>
</body>
</html>
ভিডিও দেখুন নিজে করুন
Keep Your Ads Here...
ঐতিহাসিক কালার থিওরি

এইচটিএমএল আইকন

ওয়েবের যত ফন্টস

সিএসএস এনিমেশন

হরেক রকম মেনু

রকমারি বাটন
