题目
描述
您需要在 index.html
和 style.css
文件中实现如下功能,并可以在右侧区域查看代码渲染的结果。
- 在类名为
searchbox
的盒子中添加一个文本输入元素和一个按钮,当文本输入元素输入为空时,该输入元素显示的内容为What do you want to know?
,按钮中的文本内容为search
.searchbox
是一个宽300px
,高35px
的盒子,该盒子中会采用flex 布局(弹性布局) ,为该盒子设置一条宽3px
颜色为steelblue
的实线边框- 文本输入元素宽
70%
,去除它的边框和轮廓 - 按钮元素宽
30%
,去除它的边框,该按钮背景颜色为steelblue
,文字颜色为white
,当光标经过按钮时,光标变成点击样式
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">
<link rel="stylesheet" href="./style.css">
<title>Search Box</title>
</head>
<body>
<div class="searchbox">
<input type='text' placeholder="What do you want to know?">
<button type="button">search</button>
</div>
</body>
</html>
css部分:
*{
box-sizing: border-box;
margin: 0;
padding: 0;
}
.searchbox{
display: flex;
width: 300px;
height: 35px;
border-style: solid;
border-width: 3px;
border-color: steelblue;
}
input{
width: 70%;
border: none;
outline: none;
}
button{
width: 30%;
background-color: steelblue;
color: white;
border: none;
cursor: pointer;
}
弹性布局不会的可跳转flex 布局(弹性布局)
向大家推荐一个练习弹性布局的游戏:Flexbox Froggy - A game for learning CSS flexbox(弹跳青蛙)