在响应式设计中,大多数技巧都是通过百分比值完成的,直到某个点,然后我们开始使用 @media 查询。
对于您的示例,仅使用 th 和 td 标签的百分比,我相信您可以管理它,但如果它小于 40em,则完全不同的 CSS 会进行控制,如下所示;
//when width less than 40em you can also use px
@media (max-width: 40em)
{
// show every item as a line
.movie-list td, .movie-list th {
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
float: left;
clear: left;
}
//for th and .titles display them as a big bold title with different background color
.movie-list tbody th, .movie-list tbody td.title {
display: block;
font-size: 1.2em;
line-height: 110%;
padding: .5em .5em;
background-color: #fff;
color: #77bbff;
-moz-box-shadow: 0 1px 6px rgba(0,0,0,.1);
-webkit-box-shadow: 0 1px 6px rgba(0,0,0,.1);
box-shadow: 0 1px 6px rgba(0,0,0,.1);
}
//for th only this is only for margin to override previous css
.movie-list tbody th {
margin-top: 0;
text-align: left;
}
}
希望这能有所帮助,这只是一个开始;
这是你的鱼伙伴:) 只需使用开发人员工具栏并在 h2 Live Examples 标签下添加代码即可;
<style>
// check if it is a small device ipad iphone android etc.
// google for example 'css media queries for mobile"
@media (max-width: 40em) {
// just did something to display second row use your skills
table#example tr.even
{
border: 2px solid red;
}
// exactly the same with other one to display td as rows
// with css selector you can hide first one display 2nd one like a title etc
table#example tr td
{
background-color:white;
width: 90%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
float: left;
clear: left;
}
// remove the thead as we dont need it
// you should do similar to the footer as well
table#example thead
{
display:none;
}
// hide unwanted pagination elements
table#example ~ div.fg-toolbar div#example_info,
table#example ~ div.fg-toolbar div a
{
display:none;
}
// and only display next and prev
// it s not what I actually wanted to make it more tab able make it bigger and try to cover half of the row.
table#example ~ div.fg-toolbar div a#example_previous,
table#example ~ div.fg-toolbar div a#example_next
{
display:inline-block;
width:46% !important;
}
}
</style>
据我所知,编辑和添加内容正在工作,因为这完全是 css,只是你必须深入挖掘。