如何确保我的 CSS 内容完美适合 Web 浏览器窗口?

问题描述 投票:0回答:1

如何确保我的 CSS 内容完美适合 Web 浏览器窗口?

我面临的问题是,尺寸为宽度 1917.00 x 高度 850.00 的内容超出了笔记本电脑 Chrome 浏览器窗口的边界,需要我滚动才能查看它。有趣的是,在另一台相同型号和浏览器的笔记本电脑上,内容完全适合,无需滚动。

为了缓解这个问题,我发现将笔记本电脑浏览器的缩放级别降低到 75% 可以解决该问题,从而使内容能够紧贴窗口而无需滚动条。

现在,我的问题是:在 CSS 中的哪里可以将尺寸统一调整为 75%,以确保内容完美适合每个笔记本电脑型号的浏览器窗口?我的主要目标是完全显示内容而不需要使用滚动条。

我也不希望按钮文本大小视图变小。

这是我的 CSS 代码:

body {
  background-color: #fefff4;
  background-image: linear-gradient(#fefff4, #fefff4);
  margin: 0;
}

#bannerPx {
  padding: 0;
}

/* Banner Wrapper */
#banner {
  position: relative;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  height: 40px;
  z-index: 10;
  background-color: #4fb3ff;
}

/* Banner Text */
#banner_text {
  text-align: center;
  font: bold 36px Century Gothic;
  color: #000000;
  z-index: 11;
  margin-left: 60px;
  margin-right: 60px;
}

#banner_text2 {
  margin-left: 20px;
}

#bannerimg {
  height: 100%;
}

#bannerIncludePx {
  height: 100%;
  position: relative;
}

#content {
  overflow: hidden;
  z-index: 9999;
  width: 1917px; 
  height: 870px;
}

#content iframe {
  margin: 0;
  padding: 0;
  width: 1917px;
  height: 870px;
  z-index: 300;
  background-color: #fefff4;
}

#console {
  height: 150px;
  margin-top: 0px;
  overflow: auto;
}

#console iframe {
  width: 100;%
  z-index: 200;
}

nav {
  margin: 0px 0px auto;
  position: relative;
  z-index: 2;
}

ul li img {
  margin-left: -20px;
  padding-right: 10px;
  vertical-align: middle;
}

#ci_wrapper {
  margin: 0 auto;
  width: 1917px;
  padding: 8px;
}

#menu,
#menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#menu {
  margin: 0;
  padding: 0;
  background-color: #4fb3ff;
  border-radius: 0;
  box-shadow: 0 1px 1px #777;
  position: relative;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1;
}

#menu:before,
#menu:after {
    content: "";
    display: table;
}

#menu:after {
    clear: both;
}

#menu {
    zoom:1;
}

#menu li {
    float: left;
    position: relative;
}


#menu a {
    float: left;
    padding: 10px 30px;
    color: #212121;
    text-transform: none;
    font: bold 15px Segoe UI;
    text-decoration: none;
}

#menu li:hover > a {
    color: #000000;
    background-image: linear-gradient(#4fb3ff, #4fb3ff);
}

#menu li:hover > a svg {
    transform: rotate(180deg);
}

*html #menu li a:hover { /* IE6 only */
    color: #b6c3d4;
}

#menu ul {
    margin: 20px 0 0 0;
    _margin: 0; /*IE6 only*/
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 41px;
    left: 0;
    z-index: 1;    
    background: #FFFFFF;   
    background: linear-gradient(#FFFFFF, #FFFFFF);
    box-shadow: 20px 20px 50px grey;   
    border-radius: 0px;
    transition: all .5s ease-in-out;
}

#menu li:hover > ul {
    opacity: 1;
    visibility: visible;
    margin: 0;
}

#menu ul ul {
    top: 0;
    left: 100%;
    margin: 0 0 0 20px;
    _margin: 0; /*IE6 only*/
    box-shadow: -1px 0 0 rgba(255,255,255,.3);      
}

#menu ul li {
    float: none;
    display: block;
    border: 0;
    _line-height: 0; /*IE6 only*/
    box-shadow: 0 0px 0 #111, 0 0px 0 #666;
}

#menu ul li:last-child {   
    box-shadow: none;    
}

#menu ul a {    
    padding: 10px 25px;
    _height: 10px; /*IE6 only*/
    display: block;
    white-space: nowrap;
    float: none;
    text-transform: none;
}

#menu ul a:hover {
    background-image: linear-gradient(#0095ff, #0095ff);
    color : #000000;
    font-size :14.5px;
}
#menu li a:hover {
    background-image: linear-gradient(#0095ff, #0095ff);
    color : #000000;
}

#menu ul li:first-child > a {
    border-radius: 0px 0px 0 0;
}

#menu ul li:first-child > a:after {
    content: '';
    position: absolute;
    left: 40px;
    top: -6px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #FFFFFF;
}

#menu ul ul li:first-child a:after {
    left: -6px;
    top: 50%;
    margin-top: -6px;
    border-left: 0; 
    border-bottom: 6px solid transparent;
    border-top: 6px solid transparent;
    border-right: 6px solid #FFFFFF;
}

#menu ul li:first-child a:hover:after {
}

#menu ul ul li:first-child a:hover:after {
    border-right-color: #424242; 
    border-bottom-color: transparent;   
}

#menu ul li:last-child > a {
    border-radius: 0 0 0px 0px;
}

/* Mobile */
#menu-trigger {
    display: none;
}

@media screen and (max-width: 600px) {

    #menu-wrap {
        position: relative;
    }

    #menu-wrap * {
        box-sizing: border-box;
    }

    #menu-trigger {
        display: block;
        height: 40px;
        line-height: 40px;
        cursor: pointer;        
        padding: 0 0 0 35px;
        border: 1px solid #BDBDBD;
        color: #9E9E9E;
        font-weight: bold;
        background-color: #fff;
        background: url(data:image/png;base64,iVBOR...) no-repeat 10px center, linear-gradient(#BDBDBD, #111);
        border-radius: 6px;
        box-shadow: 0 1px 1px #777, 0 1px 0 #666 inset;
    }

    #menu {
        margin: 0; padding: 10px;
        position: absolute;
        top: 40px;
        width: 100%;
        z-index: 1;
        display: none;
        box-shadow: none;       
    }

    #menu:after {
        content: '';
        position: absolute;
        left: 25px;
        top: -8px;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-bottom: 8px solid #BDBDBD;
    }   

    #menu ul {
        position: static;
        visibility: visible;
        opacity: 1;
        margin: 0;
        background: none;
        box-shadow: none;               
    }

    #menu ul ul {
        margin: 0 0 0 20px !important;
        box-shadow: none;       
    }

    #menu li {
        position: static;
        display: block;
        float: none;
        border: 0;
        margin: 5px;
        box-shadow: none;           
    }

    #menu ul li{
        margin-left: 20px;
        box-shadow: none;       
    }

    #menu a{
        display: block;
        float: none;
        padding: 0;
        color: #212121;
    }

    #menu a:hover{
        color: #9E9E9E;
    }   

    #menu ul a{
        padding: 0;
        width: auto;        
    }

    #menu ul a:hover{
        background: none;   
    }

    #menu ul li:first-child a:after,
    #menu ul ul li:first-child a:after {
        border: 0;
    }    

}

@media screen and (min-width: 600px) {
    #menu {
        display: block !important;
    }
}   

/* iPad */
.no-transition {
    transition: none;
    opacity: 1;
    visibility: visible;
    display: none;          
}

#menu li:hover > .no-transition {
    display: block;
    background-color: #b6c3d4;
}
svg {
    transition: transform 0.5s ease;
    overflow: hidden;
}
#menu li a img {
    float: left;
}
html css user-interface iframe
1个回答
0
投票

在 HTML 代码中,将

meta
标签添加到
header
:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

这应该让浏览器知道如何根据设备宽度缩放页面。

© www.soinside.com 2019 - 2024. All rights reserved.