실전퍼블리싱(배경이미지 풀스크린 검색창)

Dev_Go·2022년 7월 19일
0
post-thumbnail

배경이미지 풀스크린 검색창


폼관련 가상클래스를 활용한 배경 이미지 풀스크린 검색창 만들기

예제보기

HTML

  <form class="search">
    <h1>What are you looking for?</h1>
    <input type="text" placeholder="Type...">
    <input type="submit" value="Search">
  </form>

CSS

/* Google Web Font */
@import url('https://fonts.googleapis.com/css?family=Montserrat:300,400,500&display=swap');

body {
  font-family: 'Montserrat', sans-serif;
  line-height: 1.5em;
  margin: 0;
  font-weight: 300;
  /* background-image: url('../images/snow-photo.jpg');
  background-repeat: no-repeat;
  background-position: center center;
  background-attachment: fixed; */
  background: url('../images/snow-photo.jpg') no-repeat center center fixed;
}
body::before {
  content: '';
  position: absolute;
  background-color: rgba(0, 0, 0, 0.65);
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: -1;
}
a {
  text-decoration: none;
  color: #222;
}

.search {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.search h1 {
  color: #fff;
  text-align: center;
  font-weight: normal;
  margin-bottom: 30px;
  font-size: 36px;
}
.search input[type=text],
.search input[type=submit] {
  padding: 20px;
  border: none;
  outline: none;
  box-sizing: border-box;
}
.search input[type=text] {
  width: 350px;
  margin-right: -6px;
  padding-left: 40px;
  border-radius: 40px 0 0 40px;
}
.search input[type=submit] {
  width: 150px;
  border-radius: 0 40px 40px 0;
  cursor: pointer;
  background-color: orange;
  color: #fff;
}
.search input[type=submit]:hover {
  background-color: darkgoldenrod;
}
.search input[type=text]::placeholder {
  font-size: 20px;
  font-style: italic;
}
profile
프론트엔드 4년차

0개의 댓글