- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在移动 View 上处理我的网站导航,一个纯 css 汉堡菜单,我的问题是标题(包括 Logo 和汉堡菜单)和我的导航的下拉列表之间存在间隙。
/*
html5doctor.com Reset Stylesheet
v1.6.1
Last Updated: 2010-09-17
Author: Richard Clark - http://richclarkdesign.com
Twitter: @rich_clark
*/
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure,
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
body {
line-height:1;
}
article,aside,details,figcaption,figure,
footer,header,hgroup,menu,nav,section {
display:block;
}
nav ul {
list-style:none;
}
blockquote, q {
quotes:none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content:'';
content:none;
}
a {
margin:0;
padding:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
/* change colours to suit your needs */
ins {
background-color:#ff9;
color:#000;
text-decoration:none;
}
/* change colours to suit your needs */
mark {
background-color:#ff9;
color:#000;
font-style:italic;
font-weight:bold;
}
del {
text-decoration: line-through;
}
abbr[title], dfn[title] {
border-bottom:1px dotted;
cursor:help;
}
table {
border-collapse:collapse;
border-spacing:0;
}
/* change border colour to suit your needs */
hr {
display:block;
height:1px;
border:0;
border-top:1px solid #cccccc;
margin:1em 0;
padding:0;
}
input, select {
vertical-align:middle;
}
/*--------------MY CODE----------*/
/*--------------MY CODE----------*/
/*MOBILE VIEW*/
* {
text-decoration: none;
font-family: Catamaran, sans-serif;
}
header {
background-color: #dbd3d34b;
height: 100px;
box-shadow: 1px 1px rgb(177, 175, 175);
z-index: 1;
}
.logo {
display: block;
float: left;
margin: 27px 0;
}
.logo img{
width: 200px;
height: 50px;
}
nav ul {
overflow: hidden;
}
nav ul li a {
display: block;
background-color: #f2f2f2;
font-family: Roboto, sans-serif;
font-size: 16px;
padding: 20px;
font-weight: 400;
color: #111;
border-bottom: 1px solid rgb(8, 189, 53);
position: relative;
z-index: 1;
}
nav ul li a:hover {
color: rgb(8, 189, 53);
}
/*-------HAMBURGER MENU-------------*/
nav ul {
border: 1px solid red;
}
nav .menu {
clear: both;
max-height: 0;
transition: max-height .2s ease-out;
}
nav .menu-icon {
margin: 30px 0;
padding: 20px 15px;
position: relative;
float: right;
}
nav .menu-icon .nav-icon {
background-color: #111;
display: block;
height: 3px;
width: 25px;
position: relative;
transition: background .2s ease-out;
}
nav .menu-icon .nav-icon:before {
background-color: #111;
content:"";
height: 100%;
width: 100%;
position: absolute;
transition: all .2s ease-out;
top: 7px;
}
nav .menu-icon .nav-icon:after {
background-color: #111;
content:"";
height: 100%;
width: 100%;
position: absolute;
transition: all .2s ease-out;
bottom: 7px;
}
.menu-btn {
display: none;
}
nav .menu-btn:checked ~ .menu {
max-height: 260px;
}
nav .menu-btn:checked ~ .menu-icon .nav-icon {
background-color:transparent;
}
nav .menu-btn:checked ~ .menu-icon .nav-icon:before {
transform: rotate(-45deg);
top:0;
}
nav .menu-btn:checked ~ .menu-icon .nav-icon:after {
transform: rotate(45deg);
top:0;
}
/*----END OF HAMBERGER MENU*/
/*---------DESKTOP DISPLAY*/
@media only screen and (min-width: 1000px) {
.menu-btn {
display: none;
}
nav .menu {
clear: none;
max-height: none;
}
nav .menu-icon {
display: none
}
.logo {
display: block;
float: left;
margin: 4px 0;
}
.logo img{
width: 380px;
height: 86px;
}
nav {
float : right;
width: 600px;
height: 100px;
margin-right: 80px;
}
nav ul {
height: inherit;
display: flex;
flex-flow: row;
justify-content: space-between;
align-items: center;
}
nav ul li a {
font-size: 24px;
font-weight: 600;
color: #111;
border-bottom: none;
}
.main {
background-image: url("img/header.jpg");
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
width: 100%;
height: 400px;
margin-top: 1px;
display: flex;
justify-content: center;
align-items: center;
}
.main .header-text{
width: 600px;
text-align: center;
}
.main .header-text h1{
font-size: 68px;
color: #f2f2f2;
text-shadow: 1px 1px #111, -0.5px -0.5px #111;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0 , maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type ="text/css" href="main-page.css">
<title>Portfolio Michael</title>
</head>
<body>
<header class="header">
<div class="logo">
<img src="img/logo.png" alt="Web Page Logo">
</div>
<nav>
<input class="menu-btn" type="checkbox" id="menu-btn">
<label class="menu-icon" for="menu-btn"><span class="nav-icon"></span></label>
<ul class="menu">
<li><a href="#">Excercises</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">About</a></li>
</ul>
</nav>
</header>
<main>
<section class="main">
<div class="header-text">
<h1>Hi! I'm Michael! And this is my Website</h1>
</div>
</section>
</main>
</body>
</html>
我试图在我的“导航菜单”中添加负边距顶部和边距 0,但没有任何反应。
最佳答案
问题出在 nav .menu
您只需在 CSS 中指定 0
的边距即可解决此问题。
nav .menu {
clear: both;
max-height: 0;
transition: max-height 0.2s ease-out;
margin: 0;
}
关于html - 在移动 View 中删除不必要的边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58326034/
jQuery attributeContainsPrefix [name^="value"] 对比 attributeStartsWith [name|="value"] 实际区别是什么? 最佳答案
在1.1部分在RFC 6749中,有四种角色:资源拥有者、资源服务器、客户端和授权服务器。 如果客户端和资源所有者是同一实体,OAuth 是否变得多余或不必要? 例如,我有一个封闭的 API 和一个面
我有一段代码,其中有一个带有保护子句的 raise 语句: def validate_index index # Change to SizeError raise ArgumentError
我看到了这篇文章( JPA Entity Lifecycle Events vs database trigger ),但它并没有像我在这里那样明确地询问: 当我插入 PK 值为 (null) 的行时
所以,我有一段代码看起来像 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2){ // Do something }
我是一名优秀的程序员,十分优秀!