修改以下代码实现四列在同一排上<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>底部设计</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <style> footer { background-color: #f5f5f5; padding: 50px 0;} footer h4 { font-size: 18px; font-weight: bold;} footer p { font-size: 14px; line-height: 1.5;} footer ul { list-style: none; padding: 0; margin: 0;} footer ul li { margin-bottom: 10px;} footer ul li a { color: #333; font-size: 14px; line-height: 1.5; text-decoration: none;} footer ul li a:hover { text-decoration: underline;} </style> </head> <body> <footer> <div class="container"> <div class="row"> <div class="col-md-3 col-sm-6"> <h4>关于我们</h4> <p>我们是一家专业的电商公司,致力于为客户提供高品质的商品和服务。</p> </div> <div class="col-md-3 col-sm-6"> <h4>联系我们</h4> <p>电话:123-456-7890</p> <p>邮箱:info@ecommerce.com</p> </div> <div class="col-md-3 col-sm-6"> <h4>购物指南</h4> <ul> <li><a href="#">购物流程</a></li> <li><a href="#">注册登录</a></li> <li><a href="#">会员中心</a></li> <li><a href="#">支付方式</a></li> </ul> </div> <div class="col-md-3 col-sm-6"> <h4>合作伙伴</h4> <ul> <li><a href="#">京东</a></li> <li><a href="#">淘宝</a></li> <li><a href="#">天猫</a></li> <li><a href="#">苏宁</a></li> </ul> </div> </div> </div> </footer> </body> </html>变成一行四列
时间: 2023-08-14 08:08:32 浏览: 173
可以将每个col-md-3和col-sm-6改为col-md-3 col-sm-3,这样每个列的宽度就会变成四分之一,实现四列在同一行上。修改后的代码如下:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>底部设计</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
footer {
background-color: #f5f5f5;
padding: 50px 0;
}
footer h4 {
font-size: 18px;
font-weight: bold;
}
footer p {
font-size: 14px;
line-height: 1.5;
}
footer ul {
list-style: none;
padding: 0;
margin: 0;
}
footer ul li {
margin-bottom: 10px;
}
footer ul li a {
color: #333;
font-size: 14px;
line-height: 1.5;
text-decoration: none;
}
footer ul li a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<footer>
<div class="container">
<div class="row">
<div class="col-md-3 col-sm-3">
<h4>关于我们</h4>
<p>我们是一家专业的电商公司,致力于为客户提供高品质的商品和服务。</p>
</div>
<div class="col-md-3 col-sm-3">
<h4>联系我们</h4>
<p>电话:123-456-7890</p>
<p>邮箱:info@ecommerce.com</p>
</div>
<div class="col-md-3 col-sm-3">
<h4>购物指南</h4>
<ul>
<li><a href="#">购物流程</a></li>
<li><a href="#">注册登录</a></li>
<li><a href="#">会员中心</a></li>
<li><a href="#">支付方式</a></li>
</ul>
</div>
<div class="col-md-3 col-sm-3">
<h4>合作伙伴</h4>
<ul>
<li><a href="#">京东</a></li>
<li><a href="#">淘宝</a></li>
<li><a href="#">天猫</a></li>
<li><a href="#">苏宁</a></li>
</ul>
</div>
</div>
</div>
</footer>
</body>
</html>
```
阅读全文