扁平风格的设计语言已经成为了网页设计领域中的一股强势潮流,这种设计风格简洁、干净,适合展示各种信息。价格表是网站中经常出现的一个组件,今天我们来分享一下使用CSS3扁平风格设计价格表的布局样式代码。 ...
扁平风格的设计语言已经成为了网页设计领域中的一股强势潮流,这种设计风格简洁、干净,适合展示各种信息。价格表是网站中经常出现的一个组件,今天我们来分享一下使用CSS3扁平风格设计价格表的布局样式代码。
.price-table {
display: flex; /* 将价格表中各个项目水平排列 */
flex-wrap: wrap; /* 自动换行适应不同屏幕大小 */
justify-content: center; /* 水平居中 */
}
.price-item {
margin: 20px; /* 间距 */
padding: 20px;
width: 300px;
text-align: center; /* 文本居中 */
border-radius: 5px;
background-color: #fff;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); /* 添加阴影 */
transition: all 0.3s ease-in-out; /* 添加过渡效果 */
}
.price-item:hover {
transform: translateY(-10px);
box-shadow: 0px 15px 20px rgba(0, 0, 0, 0.2);
}
.price-item .price-header {
margin-bottom: 20px;
font-size: 24px;
font-weight: bold;
color: #333;
}
.price-item .price-footer{
margin-top: 20px;
}
.price-item .btn {
padding: 10px 20px;
font-size: 18px;
color: #fff;
border: none;
border-radius: 5px;
background-color: #4ecdc4;
cursor: pointer;
transition: all 0.3s ease-in-out;
}
.price-item .btn:hover {
background-color: #3baba4;
} 在代码中,我们使用了flexbox布局来实现横向排列。通过设置元素样式,我们可以实现扁平化的效果,例如背景色、圆角、阴影、过渡等。同时,我们还可以通过:hover伪类添加鼠标悬停效果。价格表的头部和底部都有自己的样式设置,其中底部还包括了自定义的按钮样式。整个代码简单易懂,你也可以根据自己的需求进行调整。