html - 正文内容在 x 轴上溢出

标签 html css browser

我正在重新创建网站以练习我的 html 和 css 技能。 我先做移动设备,当我在 Iphone 6/7/8 ( 375x667 ) 上设置我的设备宽度/高度时(当然其他宽度也可能如此)正文内容溢出到视口(viewport)边框的右侧。

我知道这可能是太多的代码,但我真的坚持这一点,我真的不知道是什么导致了这个问题。

我正在 Opera 开发者工具中预览它。

提前致谢。

CSS:

    body {
    background-color: #fff;
    font-family: sans-serif;
    overflow: auto;
}

/* NAVIGATION HEADER */

header {
    display: flex;
    height: 80px;
    max-width: 100%;
}

.logo {
    flex-basis: 27%;
    padding: 14px 5px;
}

.menu {
    list-style-type: none;
    flex-basis: 70%;
}

.menu li {
    display: inline-block;
    padding: 20px 3px;


}

.menu a {
    text-decoration: none;
    color: #595959;
    font-size: 20px;
}

/* HERO */

.hero {
    position: relative;
    text-align: center;
}

h1 {
    font-size: 39px;
    font-weight: 800;
    text-align: center;
    line-height: 1;
    margin-top: 55px;
}

.hero h3 {
    text-align: center;
    font-size: 19px;
    font-weight: normal;
    color: #595959;
    word-wrap: normal;
    margin: 20px 20px;
}

.button {
   /* position: absolute; */
    display: inline-block;
    background-color: #e54545;
    padding: 8px 26px;
    padding-top: 13px;
    border-radius: 60px;
    color: white;
    line-height: 1.5;
    font-size: 18px;
    text-align: center;
    font-weight: 400;
}

/*
.seework {
    top: 230px;
    left: 30%;
}
*/

.bckgrnd {
    position: relative;
    display: inline-block;
    background-image: url("pozadina.png");
    background-size: cover;
    background-position: center;
    width: 100%;
    height: 250px;
    top: -50px;
    z-index: -1;
    margin: 0;
}

.strelica {
    display: inline-block;
    position: relative;
    font-size: 30px;
    font-weight: bold;
    color: #595959;
    z-index: 2;
    text-align: center;
    top: 80%;
    border: 2px solid #595959;
    box-sizing: border-box;
    padding: 1px 12px 6px;
    border-radius: 50%;
}

/* SIVI SKROL*/

.skrol {
    position: relative;
    left: 0;
    background-color: #595959;
    padding: 20px;
    margin: 0;
    min-width: 100%;
}


@media(min-width: 750px) {
    .logomob {
        display: none;
    }
}

@media(max-width: 750px) {
    .logodesk {
        display: none;
    }
}

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>nLight - User Experiance & User Interface Design Studio</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header> 
        <div class="logo">
            <img src="logomob.png" alt="nLight logo" class="logomob hidedesk"> 
            <img src="logodesk.png" alt="nLight logo" class="logodesk hidemob">
        </div>
        <nav>
            <ul class="menu">
                <li><a href="">Work</a></li>
                <li><a href="">About</a></li>
                <li><a href="">Contact</a></li>
            </ul>
        </nav>
    </header>
    <section class="hero">
        <h1>Independent Interface design studio.</h1>
        <h3>We are located in sunny Novi Sad, Europe, and work with people worldwide</h3>
        <div class="button seework">See Work</div>
        <div class="bckgrnd"> <div class="strelica"> ↓ </div> </div>
    </section>
    <section class="skrol">
        <div class="skrolhed">
            <h2> Simple solutions to complex problems. </h2>
            <p> User Experience / Interface Design & Front-end Development.
                One man studio. 10+ years of experience. 
            </p>
        </div>
        <div class="skrolbox1">
            <em>DESIGN</em>
            <h3>We do Interface design and we are serious about it.</h3>
            <p>Web applications, SAAS, marketing web sites. From discovery, prototyping, and design, through iterations to final product.</p>
        </div>
        <div class="skrolbox2">
            <em>DEVELOPMENT</em>
            <h3>Front-end Development</h3>
            <p>Creating front end strategy that scales. Including living style guide, documentation and methodology to on-board new developers.</p>
        </div>
        <div class="button about">About Us</div>
    </section>
    <footer>
        <img src="logofut.png" alt="nLight logo" class="logofut">
        <p>© 2019 nLight. Hand Made in Europe.</p>
    </footer>
</body>
</html>

最佳答案

不确定这是否是您正在寻找的修复程序,但是将 min-width: 100% 替换为 max-width: 100% for skrol 似乎可以做到。

.skrol {
    position: relative;
    left: 0;
    background-color: #595959;
    padding: 20px;
    margin: 0;
    max-width: 100%; /*instead of min-width*/
}

关于html - 正文内容在 x 轴上溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59707912/

相关文章:

javascript - 如何在 4th 之后包装所有元素

html - 如何将 div 等的这种静态对齐方式转换为始终动态对齐(即 flex )- HTML、CSS3

Android:推送通知点击后打开外部浏览器

javascript - 如何根据规范严格检查我的 html、css 和 js 源?

html - 使 Iframe 适合父 div

html - 刷新前页面无法正常显示

css - 在 Magnific Popup 中的弹出图像周围放置一个黑色边框

javascript - 在元素中使用 Node.js 作为独立的 LESS 编译器?

css - 是什么让这个水平滚动条弹出?

css - 如何在浏览器屏幕缩小时显示水平滚动条