简体   繁体   中英

How to make divs stretch horizontally across the page using pixels and not percentage?

基本上我不想使用百分比,因为像素更容易使用,因为我知道东西的确切尺寸,因此我想将页面宽度设置为1024像素宽,但可以拉伸以适合任何(大多数)常见分辨率

In modern browsers you can use @media

   @media only screen and (min-device-width: 800px) and (max-device-width: 1023px)  {
            #myDiv{width: 800px;}
    }

    @media only screen and (min-device-width: 1024px) and (max-device-width: 1279px)  {
            #myDiv{width: 1024px;}
    }

In old browsers use fixed size or make some js tricks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM