纯 css 画一个 MacBookAir
使用纯CSS绘制一个简化版的MacBook Air可以通过使用border
和border-radius
等属性来实现。以下是一个简单的例子:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MacBook Air</title>
<style>
.macbook {
width: 200px;
height: 280px;
border: 1px solid #000;
border-radius: 2px;
position: relative;
background: #fff;
}
.screen {
width: 156px;
height: 170px;
background-color: #000;
position: absolute;
top: 30px;
left: 38px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.camera {
width: 4px;
height: 4px;
background: #000;
position: absolute;
top: 10px;
left: 50px;
border-radius: 50%;
}
.camera.right {
top: 10px;
left: 146px;
}
.top-bar {
width: 188px;
height: 6px;
background: #000;
position: absolute;
top: 22px;
left: 38px;
border-radius: 4px;
}
.bottom-bar {
width: 188px;
height: 6px;
background: #000;
position: absolute;
top: 222px;
left: 38px;
border-radius: 4px;
}
.keys {
width: 200px;
height: 50px;
background: #000;
position: absolute;
top: 228px;
left: 0;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
.logo {
width: 50px;
height: 50px;
background-color: #000;
position: absolute;
top: 10px;
left: 10px;
border-radius: 4px;
}
.slot {
width: 20px;
height: 8px;
background: #000;
position: absolute;
top: 120px;
left: 48px;
border-radius: 4px;
}
.speaker {
width: 20px;
height: 8px;
background: #000;
position: absolute;
top: 134px;
left: 108px;
border-radius: 4px;
}
.handle {
width: 10px;
height: 6px;
background: #000;
position: absolute;
top: 148px;
left: 84px;
border-radius: 4px;
}
.handle.right {
top: 148px;
left: 116px;
}
.base {
width: 200px;
height: 8px;
background: #000;
position: absolute;
top: 270px;
left: 0;
border-bottom-left-radius: 4px;
border-bottom-righ
评论已关闭