Small Project : Kết hợp 3 kiểu dùng CSS

DevNotes
By -
0

Cấu trúc:

Dùng inline Css cho nút nhấn

dùng internal css cho layout

dùng external css cho card design

cấu trúc thư mục

project/

│── index.html

│── styles.css   (external CSS)

Index.html

[code lang="html"]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profile Card</title>
<!-- external css -->
<link rel="stylesheet" href="style.css">
<!-- internal css -->
<style>
.container {
display: flex;
justify-content: center;
margin-top: 40px;

}
</style>
</head>

<body>
<div class="container">
<div class="card">
<img src="https://i.pravatar.cc/150?img=3" alt="Profile">
<h2>John Doe</h2>
<p>Fontend Dev</p>
<!-- inline css -->
<button style="background: #4CAF50;
color: white; padding: 10px 20px;
border: none;border-radius: 5px;
cursor: pointer;">
Follow
</button>
</div>
</div>
</body>

</html>
[/code]

style.css

[code lang="css"]
body {
font-family: Arial, Helvetica, sans-serif;
background: #f4f4f4;
margin: 0;
padding: 20px;
}

.card {
background: #ffffff;
width: 280px;
padding: 20px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
text-align: center;
margin: 0 auto;
}

.card img {
width: 120px;
height: 120px;
border-radius: 50%;
}

.card h2 {
margin: 10px 0 5px;

}

.card p {
color: #666;
}
[/code]

Kết quả



Tags:

Đăng nhận xét

0 Nhận xét

Đăng nhận xét (0)
3/related/default