ওয়েব ডিজাইন (পর্ব ১২)পজিশন, ডিসপ্লে, অভার ফ্লো, ফ্লোট

CSS Display এর প্রধান কাজ আমাদের লেআউট কে কন্ট্রোল করা।এইটা খুবই গুরুত্বপূর্ণ । Display প্রোপার্টি এর ব্লক লেভেল ও ইনলাইন এলিমেন্ট কিছু ট্যাগ দেখি নে

ওয়েব ডিজাইন (পর্ব ১২)পজিশন, ডিসপ্লে, অভার ফ্লো, ফ্লোট

আস্‌সালামু আলাইকুম! আশা করি আল্লাহ এর অশেষ রহমতে আপনারা সবাই ভালো আছেন।আমিও আপনাদের দোয়াই ভালো আছি। আজকের নতুন টপিকে আপনাকে স্বাগতম! আজকে আপনাদের দেখাবো পজিশন, ডিসপ্লে, অভার ফ্লো,ফ্লোট।

ডিসপ্লেঃ(Display)

CSS Display এর প্রধান কাজ আমাদের লেআউট কে কন্ট্রোল করা।এইটা খুবই গুরুত্বপূর্ণ ।
Display প্রোপার্টি এর ব্লক  লেভেল ও ইনলাইন এলিমেন্ট কিছু ট্যাগ দেখি নেই।

ব্লক লেভেল এলিমেন্টঃ(Block lavel Element)

Block-level এলিমেন্ট গুলো পুরো width এর জায়গা নিয়ে নেয়।
  • <div>
  • <h1> - <h6>
  • <p>
  • <form>
  • <header>
  • <footer>
  • <section>

ইনলাইন এলিমেন্টঃ(Inline Element)

inline element গুলো একই লাইনে অবস্থান করতে পারে।
  • <span>
  • <a>
  • <img>
আমি নিচের কোডে দেখানোর চেস্টা করেছি div যদিও Block Element তবুও কিভাবে আপনারা CSS এর মাধ্যমে inline এলিমেন্ট বানিয়ে ফেলবেন।
<style>
div {
display:inline;
}
</style>
<span> This is inline </span>
<div> it's block element but css use inline</div>

Inline-Block Vs. Inline:

Display প্রোপার্টি এর inline-block ও inline ভেলু এর মধ্যে অনেকটা আলাদা বিষয় আছে যা আমাদের অবশ্যই জানা প্রয়োজন।এইটা না জানলে আপনারা কিছু ডিজাইনের কোনো সমস্যা তৈরি হতে পারে।
inline-block এ পুরো জায়গা ধরে রাখে না কিন্তু ব্লক পুরো জায়গা ধরে রাখে যার কারনে অন্য কন্টেন্ট ওই কন্টেন্ট এর নিচে তে অবস্থান করে।
নিচের কোডে খেয়াল করলে বুঝা যাবে দুইটার মধ্যে পার্থক্য কি
<style type="text/css">
.a{
display:inline-block;
height:150px;
width:150px;
background-color:yellow;
border:1px solid red;
}
.b{
display:block;
height:150px;
width:150px;
background: yellow;
border: 1px solid red;
}
</style>
<!-- Inline Block Start-->
<span class="a">Lorem</span>
<span class="a">Ipsum</span>
<!-- inline block end-->
<br />
<br />
<br />
<!-- Block start-->
<span class="b">Lorem</span>
<span class="b">Ipsum</span>
<!-- Block End-->

Display None:

ডিসপ্লে নান করা মানে কোনো কোড লিখে সেইটা কে যদি আমাদের ওয়েব পেজে দেখাতে না চাই বা কোনো নির্দিষ্ট কারনে দেখাতে চায়। তবেই এই  display:none করার প্রয়োজন পড়ে।
<style>
div {
display:none;
}
</style>
<span> This is no none </span>
<div> it's display none</div>

পজিশনঃ(Position)

CSS এর আরেকটি গুরুত্বপূর্ণ প্রোপার্টি হলো পজিশন।পজিশন দিয়ে আমরা আমাদের সাইটের ডিজাইন জায়গা মতো স্থাপন করতে পারি। নয়তো সম্ভব না।

পোজিশন প্রোপার্টিতে যে সব ভেলু ইউজ হয়ে থাকে তা হলোঃ
  • static = এইটা ডিফল্ট। এইটা সাধারণত ইউজ করলেও যেমন ছিলো তেমন ই থাকে।তবে কিছু ক্ষেত্রে এইটা ব্যবহারের দরকার হয়।
  • relative = রিলেটিভ Static এর মতোই তবে top, right, bottom, right ব্যবহার করে নিজস্ব অবস্থানের ভিতরে সরানো যাবে।
  • absolute =  নির্দিষ্ট  Div এর ভিতরে অবস্থান করবে।যদি কোনো নির্দিষ্ট  ডিভ এর ভিতরে  না থাকে তবে <html> কে অনুসরণ করে অবস্থান করবে এবং অবস্থান পরিবর্তন করবে।
  • fixed = এটা সব সময় নির্দিষ্ট জায়গায় অবস্থান করে।স্ক্রল করলেও Fixed জায়গা থেকে সরে না।
  • sticky = এইটা আমাদের স্ক্রলিং এর পজিশন নিশ্চিত করে।নির্দিষ্ট জায়গা থেকে sticky করা সম্ভব।
আমরা এখন Relative এবং Absolute ব্যবহার করে বাংলাদেশ এর পতাকা বানানো দেখবো যতে করে আপনাদের এই সম্পর্কে পরিস্কার ধারনা তৈরি হয়।
<style>.flag{
  background:green;
  width:600px;
  height:350px;
  position:relative;
}
.red{
  background:red;
  width:180px;
  height:180px;
  right:0px;
  left:0px;
  top:0px;
  bottom:0px;
  margin:auto;
  position:absolute;
  border-radius:100%;
}
</style>
<div class="flag"><div class="red"></div></div>

Sticky Vs Fixed

প্রায় একই রকম মনে হতে পারে । তবে দুইটার কাজ আলাদা। Sticky ভেলু সব সময় স্ক্রলিং পজিশন অনুয়ায়ী সরে। আর Fixed স্ক্রলিং এর সময়  একই জায়গায় অবস্থান করে ।
নিচের কোডে লক্ষ করুন এবং sticky ও Fixed এর তফাত বুঝতে Position প্রোপার্টি এর ভেলু Sticky চেন্জ করে Fixed করে দেখুন।
<style>
.sticky {
  position: sticky;
  padding: 10px;
  top: 0;
  background-color: #eee;
  border: 2px solid #000;
}
.large-bottom{
padding-bottom:2000px;
}
</style>
<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 class="sticky">Sticky Code</div>
<div class="large-bottom">
  <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
  <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
</p>
</div>

CSS অভার ফ্লোঃ(Overflow)

নির্দিষ্ট মাপের অতিরিক্ত কন্টেন্ট গুলো সাধারনত মাপের বাইরে অবস্থান করে।আর এই সমস্যা সমাধানের জন্য এই অভার overflow ইউজ করা হয়।
  • visible = এইটা ডিফল্ট ভাবেই থাকে।
  • hidden = এইটা ইউজ করলে আপনার মাপের বাইরে কিছু দেখা যাবেনা। তা হাইড হয়ে যাবে।
  • scroll = স্ক্রোল ইউজ করলে  মাপের বেশি হলে স্ক্রলিং হবে।
  • auto = এই টাও সাধারণত স্ক্রোলিং হবে।তবে এইটা প্রয়োজন অনুযায়ী 
নিচের কোড ট্রাই করার সময় আলাদা ভেলু ইউজ লিখবেন।
<style>
div {
  width: 300px;
  height: 100px; 
  overflow: visible;
  border: 1px dotted black;
  background-color: #ffcccc;}
</style>
<div>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.</div>

CSS ফ্লোটঃ(Float)

লেআউট তৈরি করার জন্য ফ্লোট খুব গুরুত্বপূর্ণটা একটা বিষয়।আমরা আমাদের কন্টেন্ট কে সাজাতে অর্থাৎ কোনটা কোন পাশে রাখবো তা নিশ্চিৎ করতে এই সিএসএস ফ্লোট ব্যবহার করা হয়।
 একই সাথে লেখা বা ছবি পাশাপাশি রাখতে ফ্লট ব্যবহার করা হয়।

Float প্রোপার্টি এর ভেলুঃ(Property Value)

  1. left - এটা দিয়ে বাম পাশে ফ্লটে নেওয়া হয়।
  2. right - এটা দিয়ে ডান পাশের ফ্লটে নেওয়া হয়।
  3. none - এইটা কোনো ফ্লট না । এটা ডিফল্ট।
ফল্ট যখন আলাদা করা হয় তখন খালি জায়গা গুলোতে নিচের কন্টেন্ট গুলো চলে আসে।আর তখন আমাদের ওই গুলো ক্লিয়ার করতে হয়।

Clear প্রোপার্টি এর ভেলুঃ(Property Value)

  1. none - এইটা ডিফল্ট।
  2. left - এটা শুধু বাম পাশ ক্লিয়ার করবে।
  3. right- এটা শুধু ডান পাশ ক্লিয়ার করবে।
  4. both - এইটা উভয় পাশ ক্লিয়ার করবে।
নিচের কোড গুলো ট্রাই করুন।
<style>
.red{
width:100px;
height:100px;
background-color:red;
float:left;
}
.green{
width:100px;
height:100px;
background-color:green;
float:right;
}
p{
clear:both;
}
</style>

<div class="red"></div>
<div class="green"></div>
<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>

Float Layout

নিচের কোডে একটা লেআউট কিভাবে তৈরি করা হয়। তার নমুনা কোড দেওয়া হলো ওগুলো ট্রাই করুন। আশা করি বুঝতে পারবে
<style>
.header{
    float:left;
    width : 100%;
    border: 1px solid;
    height: 100px;
}
.left_menu{
    width : 24.999%;
    float:left;
    border: 1px solid;
    height: 250px;
    clear: both;
}
.content{
   float: left;
   width: 74%;
   border: 1px solid;
   height: 250px;
   
}
.footer{
   float:left;
   width:100%;
   border: 1px solid;
   height: 100px;
}

</style>

<div class="header">Header</div>
  <div class="left_menu">Left Menu</div>
  <div class="content">Main Content</div>
<div class="footer">Footer</div>

 এই আর্টিকেল টি পুরোটা পড়ার জন্য আপনাকে অনেক ধন্যবাদ, এই আর্টিকেল যদি বুঝতে অসুবিধা হয় অথবা কোনো প্রশ্ন থাকে তবে কমেন্ট করুন, আশা করি আপনি উত্তর পাবেন।আর নতুুন কিছু জানার থাকলে আমাদের জানান আমরা জানানোর চেস্টা করবো। এই আর্টিকেলটি WikiJana.Com সাইটের সম্পদ তাই যদি কেউ কপি করেন তবে আপনারা অবশ্যই ক্রেডিট দিবেন নয়ত আপনার সাইট কপিরাইটের অধিনে চলে যেতে পারে।