此页面中的正文文本不仅位于汉堡图像下方,还位于右侧。如何让它从更靠近左页边缘流动,以便在较小的屏幕上看起来正常?我试过调整边距和填充设置。我试图保持这个无JavaScript。
/* Navigation Menu - Background */
.navigation {
/* critical sizing and position styles */
width: 100%;
height: 100%;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 0;
/* non-critical appearance styles */
list-style: none;
background: #000;
}
/* Navigation Menu - List items */
.nav-item {
/* non-critical appearance styles */
width: 200px;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
}
.nav-item a {
/* non-critical appearance styles */
display: block;
padding: 1em;
color: white;
font-size: 1.2em;
text-decoration: none;
transition: color 0.2s, background 0.5s;
}
.nav-item a:hover {
color: #c74438;
}
/* Site Wrapper - Everything that isn't navigation */
.site-wrap {
/* Critical position and size styles */
min-height: 100%;
min-width: 100%;
background-color: white; /* Needs a background or else the nav will show through */
position: relative;
top: 0;
bottom: 100%;
left: 2;
z-index: 1;
/* non-critical appearance styles */
padding: 4em;
padding-left: -4em;
background-size: 200%;
}
/* Nav Trigger */
.nav-trigger {
/* critical styles - hide the checkbox input */
position: absolute;
clip: rect(0, 0, 0, 0);
}
label[for="nav-trigger"] {
/* critical positioning styles */
position: fixed;
left: 15px; top: 15px;
z-index: 2;
/* non-critical appearance styles */
height: 30px;
width: 30px;
cursor: pointer;
background-image: url(http://imgur.com/S0q57Jd.jpg);
background-size: contain;
}
/* Make the Magic Happen */
.nav-trigger + label, .site-wrap {
transition: left 0.2s;
}
.nav-trigger:checked + label {
left: 215px;
}
.nav-trigger:checked ~ .site-wrap {
left: 200px;
box-shadow: 0 0 5px 5px rgba(0,0,0,0.5);
}
body {
/* Without this, the body has excess horizontal scroll when the menu is open */
overflow-x: hidden;
}
/* Additional non-critical styles */
h1, h3, p {
margin: 0 auto 1em;
}
h1 {font-size: 1.125em;}
h3 {font-size: 1em;}
p {font-size: 0.8125em;}
code {
padding: 2px;
background: #ddd;
}
/* Micro reset */
*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin:0;padding:0;}
html, body { height: 100%; width: 100%; font-family: Arial, Helvetica, sans-serif; }
<body>
<ul class="navigation">
<li class="nav-item"><a href="#">One</a></li>
<li class="nav-item"><a href="#">Two</a></li>
<li class="nav-item"><a href="#">Three</a></li>
<li class="nav-item"><a href="#">Four</a></li>
</ul>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger"></label>
<div class="site-wrap">
<h1>Title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quasi vero nisi eos sed qui natus, ut eius reprehenderit error nesciunt veniam aliquam nulla itaque labore obcaecati molestiae eveniet, perferendis provident amet perspiciatis expedita accusantium! Eveniet, quos voluptas et, labore natus, saepe unde est nulla sit eaque tempore debitis accusantium. Recusandae.</p>
<p>Dolorem aliquam a libero reiciendis obcaecati doloribus ipsa eos laudantium, dicta in! Odit iure ut ratione, dolorum cupiditate perferendis voluptatum sapiente, dignissimos sunt necessitatibus, reprehenderit consequatur dolorem. Aliquam veniam quaerat, pariatur deserunt reiciendis vero vitae, repellat omnis sequi dolor nesciunt. Nihil similique alias impedit, obcaecati eligendi delectus voluptatum! Ipsum, vel.</p>
<p>Sint, perspiciatis nemo aut, rerum excepturi deleniti modi quos nihil corporis eum, maiores soluta labore, consectetur eligendi nesciunt. Placeat, incidunt! Illum placeat eligendi, veritatis consectetur eum! Dolor obcaecati minima ab placeat voluptatem neque modi doloribus, magnam qui voluptate eaque in. Nulla expedita hic porro architecto facere officiis vitae numquam, dolor!</p>
<p>Perferendis quis ea incidunt ducimus nisi voluptate natus. Repellat asperiores quod rerum rem quos blanditiis enim modi, veniam voluptas a facilis! Velit cum omnis, voluptatum eum inventore! Corrupti, suscipit, neque distinctio expedita est laboriosam cum aliquid minus tempora quaerat officia possimus unde vel deleniti eaque fugit accusamus iusto dolorum natus. </p>
</div>
</body>
答案 0 :(得分:2)
更改此
.site-wrap {
...
padding: 4em;
padding-left: -4em;
...
}
到这个
.site-wrap {
...
padding: 4em 0;
...
}
删除第padding-left: -4em;
行
padding
属性中可以有多个值:
如果
padding
属性有四个值:
填充:25px 50px 75px 100px;
- 顶部填充为25px
- 右边填充为50px
- 底部填充为75px
- 左边填充是100px
如果
padding
属性有三个值:
填充:25px 50px 75px;
- 顶部填充为25px
- 左右填充为50px
- 底部填充为75px
如果
padding
属性有两个值:
填充:25px 50px;
- 顶部和底部填充为25px
- 左右填充为50px
如果
padding
属性有一个值:
填充:25px;
- 所有四个填充都是25px
答案 1 :(得分:0)
你在.site-wrap上有一个4em填充,非常确定它是