css布局格式
2025-03-11
26
参考资料
使用Flexbox布局:
.container { display: flex; justify-content: space-between; flex-wrap: wrap; } .item { flex: 1 1 200px; margin: 10px; }使用Grid布局:
.container { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }设置响应式布局:
@media (max-width: 768px) { .container { grid-template-columns: repeat(2, 1fr); } } @media (max-width: 480px) { .container { grid-template-columns: 1fr; } }设置头部和底部样式:
header, footer { background-color: #333; color: #fff; padding: 10px 20px; text-align: center; }设置商品卡片样式:
.product-card { background: #fff; border: 1px solid #ddd; padding: 15px; text-align: center; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .product-card img { max-width: 100%; height: auto; }设置导航栏样式:
.navbar { display: flex; justify-content: space-between; background-color: #444; padding: 10px 20px; } .navbar a { color: #fff; text-decoration: none; margin: 0 10px; }设置侧边栏样式:
.sidebar { width: 25%; background-color: #f4f4f4; padding: 15px; } .main-content { width: 75%; padding: 15px; }设置按钮样式:
.btn { background-color: #28a745; color: #fff; padding: 10px 20px; border: none; cursor: pointer; text-align: center; display: inline-block; } .btn:hover { background-color: #218838; }设置表单样式:
.form-group { margin-bottom: 15px; } .form-group label { display: block; margin-bottom: 5px; } .form-group input { width: 100%; padding: 8px; box-sizing: border-box; }设置图片轮播样式:
.carousel { position: relative; width: 100%; overflow: hidden; } .carousel img { width: 100%; display: none; } .carousel img.active { display: block; }
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
本文来自《西里网 . html 网页设计》 -- 发布时间:2025-03-29
本页链接:https://html.ciilii.com/show/news-217.html
原创声明:本篇文章均为西里网原创,由《DeepSeek-R1 模型》自动生成。内容真实性仅供参考学习。
本作品采用 知识共享署名—非商业性使用—相同方式共享 4.0 国际许可协议 (CC BY-NC-SA 4.0) 进行许可。
