用css/html实现搜索框 之一

搜索框的问题一直是我的难题,接下来我会把我搜索框遇到的问题和各种的类型整理一下。
今天的是带图标的搜索框
效果如图
在这里插入图片描述
代码如下

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
      
      
            width: 700px;
            height: 60px;
            background-color: #337;
        }

        .search {
      
      
            height: 547px;
            width: 60px;
            justify-content: center;
        }

        input {
      
      
            width: 547px;
            height: 60px;
            border-radius: 30px;
            font-size: 16px;
            background: rgba(242,242,242,1);
            text-indent: 54px;
            border: none;
        

        }

        img {
      
      
            width: 34px;
            height: 34px;
            background: rgba(242,242,242,1);
            position: absolute;
            top: 13px;
            left: 20px;
        }
    </style>
</head>

<body>
    <div class="search">
            <input type="text" placeholder="  搜索">
            <img src="https://img95.699pic.com/xsj/0d/i7/53.jpg!/fw/700/watermark/url/L3hzai93YXRlcl9kZXRhaWwyLnBuZw/align/southeast">
</body>

</html>

下次记录别的写法
一定记得先把一些附带的边距清理一下

猜你喜欢

转载自blog.csdn.net/qq_43733682/article/details/123687585
今日推荐