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

CSS দিয়ে ফর্মের ইনপুট এলিমেন্টের ভিতরে আইকন রাখার পদ্ধতি


উদাহরণ

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

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/fontawesome.min.css" />
<style>
body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
form {
    max-width: 450px;
    margin: auto;
}
.inputContainer i {
    position: absolute;
}
.inputContainer {
    width: 100%;
    margin-bottom: 10px;
}
.icon {
    padding: 15px;
    color: rgb(49, 0, 128);
    width: 70px;
    text-align: left;
}
.Field {
    width: 100%;
    padding: 10px;
    text-align: center;
    font-size: 20px;
    font-weight: 500;
}
</style>
</head>
<body>
<h1 style="text-align: center;">Icons inside input element example</h1>
<form>
<div class="inputContainer">
<i class="fa fa-user icon"> </i>
<input class="Field" type="text" placeholder="Username" />
</div>
<div class="inputContainer">
<i class="fa fa-envelope icon"> </i>
<input class="Field" type="text" placeholder="Email" />
</div>
<div class="inputContainer">
<i class="fa fa-key icon"> </i>
<input class="Field" type="password" placeholder="Password" />
</div>
</form>
</body>
</html>

আউটপুট

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

CSS দিয়ে ফর্মের ইনপুট এলিমেন্টের ভিতরে আইকন রাখার পদ্ধতি


  1. CSS দিয়ে আইকন বার (Icon Bar) তৈরি করা

  2. CSS দিয়ে আইকন বাটন তৈরি করার পদ্ধতি

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

  4. ফরম ইনপুট ফিল্ডের জন্য কিছু কম পরিচিত CSS প্রোপার্টি