Jam's story

[CSS] 검색창 만들기( 이미지 넣기, 크기늘리기) 본문

WEB/CSS

[CSS] 검색창 만들기( 이미지 넣기, 크기늘리기)

애플쩀 2022. 5. 25. 14:26
Insert title here

같은 속성을 적용하면 , 맨마지막에 쓰인 속성값이 적용된다. 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
input[type='text']{
width: 100%;
padding:12px 20px;
margin:8px 0;

box-sizing:border-box;
border:2px solid #ccc;
border-radius: 4px;

background-color: white;
background-image: url("../images/searchicon.png");
background-repeat: no-repeat;
background-position: 10px center;

/* search글자와 돋보기 사진안겹치게  */
padding-left:40px;

/* 위에도 width가 잇으면 밑에 잇는 속성으로 적용된다.  */
width:150px;

/* width을 안쓰면 모든속성이라는 뜻 */
transition:width 0.5s ease;
}
input[type='text']:focus{
width:80%;

}
</style>
</head>
<body>
<form action=""method="get">
<input type="text"name="search"placeholder="Search...">
</form>
</body>
</html>

 

Comments