简体   繁体   English

当我将屏幕尺寸调整为小于600像素时,媒体查询不起作用

[英]Media query doesn't work when i resize screen less than 600px

I have made a table under a division and used the media query to react it as responsive when screen size goes less than 600px. 当屏幕尺寸小于600px时,我已在一个分区下创建了一个表格,并使用媒体查询对其进行了响应。 But when I resize my windows less than 600px all the content under table data is come out of the division. 但是,当我将窗口的大小调整为小于600px时,表数据下的所有内容都来自该分区。 Here is the screenshot of my problem: 这是我的问题的屏幕截图:

https://postimg.org/image/tfv0fd77j/

And here is my code that I have used to make this table: 这是我用来制作此表的代码:

<div class="myfirst">
        <h1 class="myheading">About Us</h1>
        <table>
            <tr>
                <td><span>HOSTING</span><br>We have top class servers<br>to serve you what you need.</td>
                <td><span>HOSTING</span><br>We have top class servers<br>to serve you what you need.</td>
                <td><span>HOSTING</span><br>We have top class servers<br>to serve you what you need.</td>
            </tr>
        </table>
    </div>
<style>
.myfirst {
    width: 100%;
    height: 200px;
    background-color: aqua;
    margin-top: 0;
}

.myheading {
    margin-top: 0px;
    text-align: center;
    font-family: sans-serif;
}

table {
    color: black;
    padding: 25px 196px;
    font-weight: 30;
    margin-left: 75px;
}

tr {
    width: 318px;
    height: 29px;
}

td {
    border-right: 2px solid white;
    padding: 0 32px;
}

td:last-child {
    border: none;
}

@media screen and(max-width:600px) {
    .myfirst {
        width: 100%!important;
        height: 200%;
        background-color: aqua;
        margin-top: 0;
    }
    table,td,tr,span {
        float: left;
        clear: both;
        width: 100%;
        display: block;
        margin: 0px;
        padding: 0;
    }


</style>

use @media screen and (max-width:600px) Add a space between and and (max-width:600px) 使用@media screen and (max-width:600px)and(max-width:600px)之间添加一个空格

 .myfirst { width: 100%; height: 200px; background-color: aqua; margin-top: 0; } .myheading { margin-top: 0px; text-align: center; font-family: sans-serif; } table { color: black; padding: 25px 196px; font-weight: 30; margin-left: 75px; } tr { width: 318px; height: 29px; } td { border-right: 2px solid white; padding: 0 32px; } td:last-child { border: none; } @media screen and (max-width: 800px) { table,td,tr,span { margin-left: 0px!important; padding: 0; } } @media screen and (max-width: 600px) { .myfirst { width: 100%!important; height: 200%; background-color: aqua; margin-top: 0; } table,td,tr,span { float: left; clear: both; width: 100%; display: block; margin-left: 0px!important; padding: 0; } } 
 <div class="myfirst"> <h1 class="myheading">About Us</h1> <table> <tr> <td><span>HOSTING</span><br>We have top class servers<br>to serve you what you need.</td> <td><span>HOSTING</span><br>We have top class servers<br>to serve you what you need.</td> <td><span>HOSTING</span><br>We have top class servers<br>to serve you what you need.</td> </tr> </table> </div> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当屏幕大于或等于 600px 宽(包括我的代码)时,如何使用媒体查询制作一个 600px 宽的表单? - Using media queries how do I make a form that is 600px wide when the screen is greater than or equal to 600px wide (my code included)? 使用媒体查询,当屏幕宽度大于或等于 600 像素时,如何制作使用网格布局来布局标签和表单元素的表单? - With media query how do I make a form that uses grid layout to layout labels and form elements when the screen is greater than or equal to 600px wide? 当 window 宽于 600px 时,如何获得 600px 的表单元素? - How do I get a form element that is 600px when the window is wider than 600px? 仅当屏幕宽度小于 600px 时,使 div 从底部消失 850px - make div disappear 850px from bottom only when screen is less than 600px wide 如何在引导程序中为移动屏幕(小于600像素)设置完整的导航栏宽度? - How can set navbar width full for mobile-screen(less than 600px) in bootstrap? 调整到小于 600 像素时,段落不响应 100% 宽度 - Paragraph not responding to 100% width when resizing to less than 600px 按两列输入600px媒体查询时显示两个数据产品 - Display two data product when entering 600px media query by two column 使我的 2 个 div 在屏幕上堆叠小于 600px - Make my 2 divs stack on screen smaller than 600px <a>屏幕分辨率低于600像素时</a>无法隐藏<a>标签</a> - cant hide an <a> tag when the screen resolution is below 600px CSS 项目帮助。 当 window 比 600px 宽时,页面需要有一个 600px 的“表单”元素,并且 - CSS Help for a project. Page needs to have a 'form' element that is 600px when the window is wider than 600px and
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM