html - 如何仅在大型设备中添加表格样式

标签 html css twitter-bootstrap

我为小型设备设计了表格样式,但是当我为大型设备设计样式时,小型设备会出现对齐问题。如何为大型设备设计表格样式?

我的 CSS 代码

.job-list {border:1px solid #eee; padding:0px 15px 15px 15px; background:#eee;}
.single-job {width:100%; min-height:240px; background: #fff; padding:15px; margin-bottom:0px;}
.single-job h3 {font-size:20px; font-weight:bold; font-family:arial; color:#434343; }
.view_btn {padding: 8px 11px; color:#fff; background:#02bed4; border:none; margin-top:0px; float:left;}
.view_btn:hover {background:#0095a6; text-decoration:none; color:#fff;}
#first {margin-top:15px;}
.table_heading {font-size:16px; font-weight:bold;}
.table_details {font-size:15px;}

响应式表格CSS代码

@media
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px)  {

    /* Force table to not be like tables anymore */
    table, thead, tbody, th, td, tr {
        display: block;
    }

    /* Hide table headers (but not display: none;, for accessibility) */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    tr { border: 1px solid #ccc; }

    td {
        /* Behave  like a "row" */

        border-bottom: 1px solid #eee;
        position: relative;
        padding-left:40%;
        padding-bottom:4%;

    }

    td:before {
        /* Now like a table header */
        position: absolute;
        /* Top/left values mimic padding */
        top: 6px;
        left: 6px;
        width: 45%;
        padding-right: 0px;
        white-space: nowrap;
    }

    /*
    Label the data
    */
    td:nth-of-type(1):before { content: "Profile :"; color:#a94442; font-weight:bold; }
    td:nth-of-type(2):before { content: "Company :"; color:#a94442; font-weight:bold; }
    td:nth-of-type(3):before { content: "Interview :"; color:#a94442; font-weight:bold; }
    td:nth-of-type(4):before { content: "Location :"; color:#a94442; font-weight:bold; }

}

/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
    body {
        padding: 0;
        margin: 0;
        width: 320px; }
    }

/* iPads (portrait and landscape) ----------- */
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
    body {
        width: 495px;
    }
}

我的 HTML 代码

<div class="row">
<div class="col-md-9">
<div class="job-list">
    <div class="single-job" id="first">
        <h3>Balancing Technician</h3>
        <table class="my-table">
        <thead>
        <tr class="table_heading">
            <th class="text-danger">Profile</th>
            <th class="text-danger">Company </th>
            <th class="text-danger">Interview</th>
            <th class="text-danger">Location</th>
        </tr>
        </thead>
        <tbody>
        <tr class="table_details">
            <td>Age 22 - 45 Should Have Minimum 3 Years Exp</td>
            <td>Adams Ship Building And Repairs </td>
            <td>23/05/2016</td>
            <td>Dubai, United Arab Emirates</td>
        </tr>
        </tbody>
        </table>
        <a href="#" class="view_btn">View this Job</a>
    </div>
</div>

<div class="job-list">
    <div class="single-job">
        <h3>Balancing Technician</h3>
        <table class="my-table">
        <thead>
        <tr class="table_heading">
            <th class="text-danger">Profile</th>
            <th class="text-danger">Company </th>
            <th class="text-danger">Interview</th>
            <th class="text-danger">Location</th>
        </tr>
        </thead>
        <tbody>
        <tr class="table_details">
            <td>Age 22 - 45 Should Have Minimum 3 Years Exp</td>
            <td>Adams Ship Building And Repairs </td>
            <td>23/05/2016</td>
            <td>Dubai, United Arab Emirates</td>
        </tr>
        </tbody>
        </table>
        <a href="#" class="view_btn">View this Job</a>
    </div>
</div>
</div><!--end of col-md-9-->

<div class="col-md-3">
<div class="sidebar">
    <span class="single_title">Industries We Serve <hr align="left"></span>
    <ul class="industry-list">
        <li>Lorem</li>
        <li>Ipsum</li>
        <li>Dolor</li>
        <li>Sit</li>
        <li>Amet</li>
    </ul>
</div>
</div><!--end of col-md-3-->
</div><!--end of row-->

最佳答案

请尝试使用此媒体查询 @media screen and (min-width:768px){...} 仅反射(reflect)大型设备

关于html - 如何仅在大型设备中添加表格样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38123831/

相关文章:

javascript - 鼠标悬停时关闭下拉菜单的 jQuery 插件

css - 如何在一个多行换行句子中的每一行添加水平填充?

javascript - Bootstrap 3 表单中用户输入是如何提交的?

javascript - 如何使用 Bootstrap 在悬停时显示 Action 列表?

css - Div 水平滚动条 - 悬停时子 div 背景不会获得全宽

javascript - 将 eventListener 添加到 JavaScript 中动态创建的选择框?

javascript - 如何使用 JavaScript 读取 post 请求参数

html - 为什么 flex 元素不缩小过去的内容大小?

c# - 发生ajax回发时下拉列表丢失元素样式

css - Symfony 2.3 - 使用带有 LESS 的 Twitter Bootstrap 3,通过 composer setup 作为供应商安装,无法访问 Glyphicons 字体