body { margin:0; padding: 0; display: flex; flex-wrap: wrap; height: 930px; } .table-container{ flex:0.5; padding: 10px; background-color: #f7f7f7; min-width: 100px; box-sizing: border-box; border: 2px solid #999; } .graph-container{ flex: 1; padding: 10px; background-color: #f0f0f0; box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: left; justify-content: left; } .graph{ width: 45%; height: 300px; margin: 10px; background-color: #ccc; border: 1px solid #999; } @media screen and (max-width: 1200px){ .graph{ width: 45%; } } @media screen and (max-width: 800px){ .graph{ width:90%; } } 优化表格容器 使表格内容居中 突出显示表格的边框 且边框只包含到表格的内容
时间: 2024-01-11 13:03:07 浏览: 36
可以尝试添加以下样式:
.table-container {
display: flex;
justify-content: center;
align-items: center;
border-collapse: collapse; /* 去掉表格边框之间的间隙 */
border: 2px solid #999;
}
.table-container td,
.table-container th {
border: 1px solid #999;
padding: 10px;
}
.table-container th {
background-color: #f7f7f7;
font-weight: bold;
}
.table-container tr:first-child th { /* 突出显示表头 */
border-top: 2px solid #999;
}
.table-container tr:last-child td { /* 突出显示表格底部边框 */
border-bottom: 2px solid #999;
}
```
需要注意的是,这里的样式只是基础样式,需要根据具体的表格结构和需求进行修改。
相关问题
body { margin:0; padding: 0; display: flex; flex-wrap: wrap; height: 930px; } .table-container{ display: flex; justify-content: center; align-items: center; border-collapse: collapse; border: 2px solid #999; } .graph-container{ flex: 1; padding: 10px; background-color: #f0f0f0; box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: left; justify-content: left; } .graph{ width: 45%; height: 300px; margin: 10px; background-color: #ccc; border: 1px solid #999; } @media screen and (max-width: 1200px){ .graph{ width: 45%; } } @media screen and (max-width: 800px){ .graph{ width:90%; } 修改代码 让表格容器占页面的三分之一
可以将.table-container的flex属性改为flex: 1 0 33.33%;,这样就可以让表格容器占据页面的三分之一了。代码如下:
```
body {
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
height: 930px;
}
.table-container {
display: flex;
justify-content: center;
align-items: center;
border-collapse: collapse;
border: 2px solid #999;
flex: 1 0 33.33%;
}
.graph-container {
flex: 1;
padding: 10px;
background-color: #f0f0f0;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
align-items: left;
justify-content: left;
}
.graph {
width: 45%;
height: 300px;
margin: 10px;
background-color: #ccc;
border: 1px solid #999;
}
@media screen and (max-width: 1200px) {
.graph {
width: 45%;
}
}
@media screen and (max-width: 800px) {
.graph {
width: 90%;
}
}
```
编写 HTML 页面,选一个网站 主题,除了 HTML 必要的标签外,需要包含如下标签:图片、表格、表单、新页面超链接、锚点、字体、水平线、列表、Div、 通过表格控制页面布局、页面内 CSS 格式
好的,我可以为您提供一个简单的HTML页面示例,包含上述要求的标签和功能。请注意,这只是一个示例,您可以根据自己的需求和喜好进行修改和添加。
```html
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<style>
body {
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 1.5;
}
h1 {
font-size: 28px;
font-weight: bold;
text-align: center;
}
img {
max-width: 100%;
height: auto;
}
table {
border-collapse: collapse;
width: 100%;
margin-bottom: 20px;
}
th, td {
border: 1px solid #ccc;
padding: 10px;
text-align: left;
}
form {
margin-bottom: 20px;
}
input, textarea {
display: block;
margin-bottom: 10px;
padding: 5px;
border: 1px solid #ccc;
border-radius: 3px;
width: 100%;
}
button {
background-color: #007bff;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 3px;
cursor: pointer;
}
button:hover {
background-color: #0062cc;
}
ul {
list-style-type: disc;
margin-left: 20px;
margin-bottom: 20px;
}
ol {
list-style-type: decimal;
margin-left: 20px;
margin-bottom: 20px;
}
.hr {
border-top: 1px solid #ccc;
margin: 20px 0;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.row {
display: flex;
flex-wrap: wrap;
margin: 0 -10px;
}
.col {
flex: 1;
padding: 0 10px;
}
.col-2 {
flex-basis: calc(50% - 20px);
}
.col-3 {
flex-basis: calc(33.33% - 20px);
}
.col-4 {
flex-basis: calc(25% - 20px);
}
</style>
</head>
<body>
<header>
<h1>Welcome to My Website</h1>
</header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<main class="container">
<section>
<h2>Our Services</h2>
<div class="row">
<div class="col col-3">
<img src="https://via.placeholder.com/600x400" alt="Service 1">
<h3>Service 1</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et felis eros. Nam quis libero sagittis, aliquam enim sit amet, tincidunt erat. Cras non nunc vitae odio commodo sodales.</p>
</div>
<div class="col col-3">
<img src="https://via.placeholder.com/600x400" alt="Service 2">
<h3>Service 2</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et felis eros. Nam quis libero sagittis, aliquam enim sit amet, tincidunt erat. Cras non nunc vitae odio commodo sodales.</p>
</div>
<div class="col col-3">
<img src="https://via.placeholder.com/600x400" alt="Service 3">
<h3>Service 3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et felis eros. Nam quis libero sagittis, aliquam enim sit amet, tincidunt erat. Cras non nunc vitae odio commodo sodales.</p>
</div>
</div>
</section>
<section>
<h2>Contact Us</h2>
<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="message">Message:</label>
<textarea id="message" name="message" rows="5" required></textarea>
<button type="submit">Send</button>
</form>
</section>
</main>
<footer>
<hr class="hr">
<p>© 2021 My Website. All rights reserved.</p>
</footer>
</body>
</html>
```
这个示例包含了一个简单的页面布局,其中包括一个顶部标题、一个导航菜单、两个部分("Our Services" 和 "Contact Us"),以及一个页脚。页面使用了一些常见的HTML标签和CSS样式,包括:
- 图片标签 `<img>`
- 表格标签 `<table>`、`<th>` 和 `<td>`
- 表单标签 `<form>`、`<input>`、`<textarea>` 和 `<button>`
- 新页面超链接标签 `<a>`
- 锚点标签 `<a>`
- 字体样式 `<style>`
- 水平线标签 `<hr>`
- 无序列表标签 `<ul>` 和 `<li>`
- 有序列表标签 `<ol>` 和 `<li>`
- Div容器标签 `<div>`
- 通过表格控制页面布局
- 页面内CSS样式控制页面布局
这个示例可以作为您编写自己网站的起点,您可以根据自己的需求和喜好进行修改和添加。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)