【发布时间】:2018-12-29 14:13:53
【问题描述】:
根据截图,请指导我如何从页面顶部开始表格标题。
分享以下代码的一些摘录。
另外,@media 查询在 Iphone 中无法正常工作。我已经签入了一个 android 设备,它就像一个魅力。我已经尝试过 Iphone 7。
#emails {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#emails td,
#emails th {
border: 1px solid #ddd;
padding: 8px;
}
#emails tr:nth-child(even) {
background-color: #f2f2f2;
}
#emails tr:hover {
background-color: #ddd;
}
#emails th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #4CAF50;
color: white;
}
#emails2 {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#emails2 td,
#emails th {
border: 1px solid #ddd;
padding: 8px;
}
#emails2 tr:nth-child(even) {
background-color: #f2f2f2;
}
#emails2 tr:hover {
background-color: #ddd;
}
#emails2 th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #4CAF50;
color: white;
}
/*
Max width before this PARTICULAR table gets nasty
This query will take effect for any screen smaller than 760px
and also iPads specifically.
*/
@media only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px) {
/* Force table to not be like tables anymore */
#emails2 table,
#emails2 thead,
#emails2 tbody,
#emails2 th,
#emails2 td,
#emails2 tr {
display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
#emails2 th {
position: absolute;
top: -9999px;
left: -9999px;
}
#emails2 tr {
border: 1px solid #ccc;
}
#emails2 td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}
#emails2 td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
}
/*
Label the data
*/
#emails2 td:nth-of-type(1):before {
content: "Domain";
}
#emails2 td:nth-of-type(2):before {
content: "Email";
}
#emails2 td:nth-of-type(3):before {
content: "Login";
}
#emails2 td:nth-of-type(4):before {
content: "User";
}
#emails2 td:nth-of-type(5):before {
content: "Disk Quota";
}
#emails2 td:nth-of-type(6):before {
content: "Disk Used";
}
#emails2 td:nth-of-type(7):before {
content: "Used Percentage";
}
#emails2 td:nth-of-type(8):before {
content: "Delete";
}
#emails2 td:nth-of-type(9):before {
content: "Change Password";
}
}
input[type=text],
input[type=password] {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
padding: 6px 10px;
margin: 3px 0;
box-sizing: border-box;
}
input[type=button],
input[type=Submit],
input[type=reset] {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
background-color: #4CAF50;
border: none;
color: white;
padding: 6px 10px;
text-decoration: none;
margin: 3px 2px;
cursor: pointer;
<pre>
<style>...</style>
<title>...</title>
<meta/>
<meta/>
<table id="emails">
<tr class="tableheader">
<th align="center"><u>User Dashboard</u></th>
</tr>
</table>
</pre>
【问题讨论】:
-
分享代码或链接,以便我们尝试帮助
-
为什么你要把 style、meta、title 元素放在 body 里面,它必须放在 head 里面
-
代码共享。截图来自谷歌浏览器。元和标题在头部而不是身体内。甚至样式都在头部
标签: html css head document-body