কম্পিউটার টিউটোরিয়াল

CSS দিয়ে আইকনসহ ফর্ম তৈরি করার পদ্ধতি


উদাহরণ

নিচের কোডটি CSS এবং Font Awesome ব্যবহার করে ইনপুট ফিল্ডের ভিতরে আইকনসহ রেজিস্ট্রেশন ফর্ম তৈরি করার পদ্ধতি দেখায়:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
<style>
body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
* {
    box-sizing: border-box;
}
h1 {
    text-align: center;
}
form {
    max-width: 500px;
    margin: auto;
}
.fieldContainer {
    display: flex;
    width: 100%;
    margin-bottom: 15px;
}
.icon {
    font-size: 30px;
    padding: 10px;
    background: rgb(11, 9, 116);
    color: white;
    min-width: 50px;
    text-align: center;
}
.field {
    font-size: 20px;
    width: 100%;
    padding: 10px;
    outline: none;
}
.field:focus {
    border: 2px solid dodgerblue;
}
.btn {
    font-size: 24px;
    background-color: rgb(20, 60, 170);
    color: white;
    padding: 15px 20px;
    border: none;
    cursor: pointer;
    width: 100%;
    opacity: 0.9;
    border-radius: 8px;
}
.btn:hover {
    opacity: 1;
}
</style>
</head>
<body>
<h1>Register Form Example</h1>
<form action="/action_page.php">
<div class="fieldContainer">
<i class="fa fa-user icon"></i>
<input class="field" type="text" placeholder="Username" name="usrnm" />
</div>
<div class="fieldContainer">
<i class="fa fa-envelope icon"></i>
<input class="field" type="text" placeholder="Email" name="email" />
</div>
<div class="fieldContainer">
<i class="fa fa-key icon"></i>
<input class="field" type="password" placeholder="Password" name="pass"/>
</div>
<div class="fieldContainer">
<i class="fa fa-birthday-cake icon" aria-hidden="true"></i>
<input class="field" type="text" placeholder="Date of Birth" name="dob"/>
</div>
<button type="submit" class="btn">Register</button>
</form>
</body>
</html>

আউটপুট

উপরোক্ত কোড নিচের আউটপুটটি তৈরি করবে:

CSS দিয়ে আইকনসহ ফর্ম তৈরি করার পদ্ধতি


  1. CSS দিয়ে রেসপন্সিভ ইনলাইন ফর্ম তৈরি করার পদ্ধতি

  2. CSS দিয়ে কার্ড তৈরি করার পদ্ধতি

  3. CSS দিয়ে চ্যাট মেসেজ (Chat Message) তৈরি

  4. CSS দিয়ে সেকশন কাউন্টার (Section Counter) তৈরি করা