gpt4 book ai didi

css - 导航位置 "absolute"不工作

转载 作者:太空宇宙 更新时间:2023-11-04 01:52:29 26 4
gpt4 key购买 nike

我正在尝试将导航位置“菜单”移动到顶部,查看图片:

enter image description here

.site-header-layout-two .main-navigation {
position: absolute;
bottom: 0;
right: 20px;
margin: 0;
top: 1px;
}

但是如果我自动更改最高值或最低值,菜单将卡在底部。

我是不是做错了!或者有其他代码行与此冲突!如果您想检查其他内容,这是我的完整代码:

html {
font-family: sans-serif;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}

body {
margin: 0;
}

article,
aside,
details,
figcaption,
figure,
footer,
header,
main,
menu,
nav,
section,
summary {
display: block;
}

audio,
canvas,
progress,
video {
display: inline-block;
vertical-align: baseline;
}

audio:not([controls]) {
display: none;
height: 0;
}

[hidden],
template {
display: none;
}

a {
background-color: transparent;
}

a:active,
a:hover {
outline: 0;
}

abbr[title] {
border-bottom: 1px dotted;
}

b,
strong {
font-weight: bold;
}

dfn {
font-style: italic;
}

mark {
background: #ff0;
color: #000;
}

small {
font-size: 80%;
}

sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}

sup {
top: -0.5em;
}

sub {
bottom: -0.25em;
}

img {
border: 0;
}

svg:not(:root) {
overflow: hidden;
}

figure {
margin: 1em 40px;
}

hr {
box-sizing: content-box;
height: 0;
}

pre {
overflow: auto;
}

code,
kbd,
pre,
samp {
font-family: monospace, monospace;
font-size: 1em;
}

button,
input,
optgroup,
select,
textarea {
color: inherit;
font: inherit;
margin: 0;
}

button {
overflow: visible;
}

button,
select {
text-transform: none;
}

button,
html input[type="button"],
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button;
cursor: pointer;
}

button[disabled],
html input[disabled] {
cursor: default;
}

button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}

input {
line-height: normal;
}

input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box;
padding: 0;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
height: auto;
}

input[type="search"] {
-webkit-appearance: textfield;
box-sizing: content-box;
}

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}

fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}

legend {
border: 0;
padding: 0;
}

textarea {
overflow: auto;
}

optgroup {
font-weight: bold;
}

table {
border-collapse: collapse;
border-spacing: 0;
}

td,
th {
padding: 0;
}

/*---------
# Typography
----------*/
body,
button,
input,
select,
textarea {
color: #808080;
font-size: 16px;
font-size: 14px;
line-height: 1.5;
}

h1,
h2,
h3,
h4,
h5,
h6 {
clear: both;
}

p {
margin: 0 0 25px;
}

dfn,
cite,
em,
i {
font-style: italic;
}

blockquote {
margin: 0 1.5em;
}

address {
margin: 0 0 1.5em;
}

pre {
background: #eee;
font-family: "Courier 10 Pitch", Courier, monospace;
font-size: 15px;
font-size: 0.9375rem;
line-height: 1.6;
margin-bottom: 1.6em;
max-width: 100%;
overflow: auto;
padding: 1.6em;
}

code,
kbd,
tt,
var {
font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
font-size: 15px;
font-size: 0.9375rem;
}

abbr,
acronym {
border-bottom: 1px dotted #666;
cursor: help;
}

mark,
ins {
background: #fff9c0;
text-decoration: none;
}

big {
font-size: 125%;
}



/*---------
# Elements
----------*/
html {
box-sizing: border-box;
}

*,
*:before,
*:after { /* Inherit box-sizing to make it easier to change the property for components that leverage other behavior; see http://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ */
box-sizing: inherit;
}

body {
background: #FFF; /* Fallback for when there is no custom background color defined. */
background-position: center top;
background-size: cover;
}

blockquote:before,
blockquote:after,
q:before,
q:after {
content: "";
}

blockquote,
q {
quotes: "" "";
}

hr {
background-color: #ccc;
border: 0;
height: 1px;
margin-bottom: 1.5em;
}

ul,
ol {
margin: 0 0 25px 20px;
padding: 0 0 0 10px;
}
ul li,
ol li {
margin: 0 0 12px;
}

ul {
list-style: disc;
}

ol {
list-style: decimal;
}

li > ul,
li > ol {
margin-bottom: 0;
margin-left: 1.5em;
}

dt {
font-weight: bold;
}

dd {
margin: 0 1.5em 1.5em;
}

img {
height: auto; /* Make sure images are scaled correctly. */
max-width: 100%; /* Adhere to container width. */
}

figure {
margin: 0;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

table {
margin: 0 0 1.5em;
width: 100%;
}

th {
font-weight: bold;
}

h1, h2, h3, h4, h5, h6, h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
font-weight: 300;
line-height: 1.0em;
word-wrap: break-word;
color: #5E5E5E;
margin-top: 0;
}

h1 {
font-size: 32px;
margin-bottom: .55em;
}

h2 {
font-size: 28px;
margin-bottom: .65em;
}

h3 {
font-size: 22px;
margin-bottom: .8em;
}

h4 {
font-size: 20px;
margin-bottom: 1.1em;
}

h5 {
font-size: 16px;
margin-bottom: 1.3em;
}

h6 {
font-size: 14px;
margin-bottom: 1.4em;
}

.entry-content code {
display: block;
background: #f7f7f7;
border: 1px solid #D8D8D8;
padding: 10px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.09);
margin: 5px 0;
overflow-x: auto;
}


/*------------
# Navigation
------------*/
/*-----------
## Links
---------------*/
a {
text-decoration: none;
outline: none;
box-shadow: none;
}

a:visited {
}

a:hover,
a:focus,
a:active {

}

a:focus {

}

a:hover,
a:active {
outline: 0;
}

/*---------
## Menus
---------*/

.main-navigation ul {
display: block;
list-style: none;
margin: 0;
padding: 0;
}
.main-navigation li {
position: relative;
float: left;
margin: 0 5px;
text-transform: uppercase;
}
.main-navigation li a {
display: block;
text-decoration: none;
font-weight: 400;
color: #FFF;
}
.main-navigation li a span {
display: none;
}
.main-navigation ul ul {
background-color: rgba(0, 0, 0, 0.9);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
float: left;
position: absolute;
top: 57px;
left: -999em;
z-index: 99999;
display: none;
}
.main-navigation ul ul a {
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
white-space: nowrap;
text-align: left;
width: 100%;
padding: 15px 25px 15px 20px;
min-width: 190px;
float: none;
}
.main-navigation ul ul ul {
top: 1px;
}
.main-navigation ul ul li {
float: none;
width: 100%;
display: block;
margin: 0;
}
.main-navigation li:hover > a,
.main-navigation li.focus > a {
}

.main-navigation ul ul :hover > a,
.main-navigation ul ul .focus > a {
}

.main-navigation ul ul a:hover,
.main-navigation ul ul a.focus {
}

.main-navigation ul li:hover > ul,
.main-navigation ul li.focus > ul {
left: 0;
display: block;
}

.main-navigation ul ul li:hover > ul,
.main-navigation ul ul li.focus > ul {
right: 100%;
}

.main-navigation .current_page_item > a,
.main-navigation .current-menu-item > a,
.main-navigation .current_page_ancestor > a {
}

/* Small menu. */
.menu-toggle,
.main-navigation.toggled ul {
display: block;
}

#main-menu:after {
display: block;
content: '';
clear: both;
}

.header-menu-button {
display: none;
}

.menu-dropdown-btn {
display: none;
position: absolute;
top: 0;
right: 0;
background-color: rgba(255, 255, 255, 0.1);
color: #838383;
margin: 0;
padding: 10px 14px;
/* box-shadow: -1px 0 0 rgba(0, 0, 0, 0.08); */
height: 35px;
line-height: 15px;
text-align: center;
font-size: 14px;
z-index: 9;
cursor: pointer;
}

.site-main .comment-navigation,
.site-main .posts-navigation,
.site-main .post-navigation {
margin: 0 0 1.5em;
overflow: hidden;
}

.comment-navigation .nav-previous,
.posts-navigation .nav-previous,
.post-navigation .nav-previous {
float: left;
width: 50%;
}

.comment-navigation .nav-next,
.posts-navigation .nav-next,
.post-navigation .nav-next {
float: right;
text-align: right;
width: 50%;
}

/* Small menu */
.menu-toggle {
display: none;
}

.main-menu-close {
display: none;
}

/*-----------
# Accessibility
-------------*/
/* Text meant only for screen readers. */
.screen-reader-text {
clip: rect(1px, 1px, 1px, 1px);
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
}

.screen-reader-text:hover,
.screen-reader-text:active,
.screen-reader-text:focus {
background-color: #f1f1f1;
border-radius: 3px;
box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
clip: auto !important;
color: #21759b;
display: block;
font-size: 14px;
font-size: 0.875rem;
font-weight: bold;
height: auto;
left: 5px;
line-height: normal;
padding: 15px 23px 14px;
text-decoration: none;
top: 5px;
width: auto;
z-index: 100000; /* Above WP toolbar. */
}

/*--------------
# Alignments
---------------*/
.alignleft {
display: inline;
float: left;
margin-right: 1.5em;
}

.alignright {
display: inline;
float: right;
margin-left: 1.5em;
}

.aligncenter {
clear: both;
display: block;
margin-left: auto;
margin-right: auto;
}

/*-------------
# Clearings
--------------*/
.clear:before,
.clear:after,
.entry-content:before,
.entry-content:after,
.comment-content:before,
.comment-content:after,
.site-header:before,
.site-header:after,
.site-content:before,
.site-content:after,
.site-footer:before,
.site-footer:after {
content: "";
display: table;
}

.clear:after,
.entry-content:after,
.comment-content:after,
.site-header:after,
.site-content:after,
.site-footer:after {
clear: both;
}



/* -------- Header Elements -------- */

.site-header {
background-color: rgba(0, 0, 0, 0.8);
position: relative;
color: #FFF;
}
.site-header-layout-two .site-header {
box-shadow: 0 -6px 0 rgba(0, 0, 0, 0.6) inset;
padding: 0 0 5px;
}
.site-header .site-container {
position: relative;
max-width: 1280px;
}
.header-container {
position: relative;
z-index: 4;
}

.header-social-icon {
font-size: 15px;
color: inherit;
margin: 2px 0 0 10px;
display: inline-block;
vertical-align: top;
}

.site-branding {
float: left;
position: relative;
z-index: 12;
padding: 30px 0;
}
.site-branding-img {
padding: 0;
}
.site-branding a {
display: block;
line-height: inherit;
}
.site-branding a img {
display: block;
}
.site-title {
margin: 0;
padding: 0 0 10px;
font-size: 40px;
line-height: 50px;
font-weight: 300;
text-transform: uppercase;
}
.site-description {
margin: 0;
padding: 0;
font-size: 15px;
line-height: 16px;
font-weight: 300;
text-transform: uppercase;
color: inherit;
}
.site-header-right {
position: absolute;
top: 50%;
right: 20px;
margin: -70px 0 0;
text-align: right;
}
.site-header-right-txt {
margin: -52px 0 0;
}
.site-header-right-no-txt {
margin: -70px 0 0;
}
.site-header-right-no-ss {
margin: -38px 0 0;
}
.site-header-right-no-sst {
margin: -58px 0 0;
}
.site-header-signup {

}
.site-header-cart {

}
.site-header-right-top {min-height: 36px;}
.site-topbar-right-no {
font-size: 15px;
border-bottom: 1px dashed #FFF;
padding: 0 0 5px;
}
.site-topbar-right-no i.fa {
font-size: 14px;
margin: 0 2px 0 4px;
}
.site-topbar-right-no span {
font-size: 24px;
margin: 0 0 0 30px;
}
.site-header-right-bottom {
padding: 6px 0 0;
}
.site-header-social {
padding: 2px 0 0;
}
.social-pinterest span {
font-size: 11px;
position: relative;
top: -2px;
margin: 0 0 0 4px;
}

.header-cart {
display: inline-block;
vertical-align: middle;
padding: 0;
}
.header-cart a {
display: inline-block;
vertical-align: middle;
color: inherit;
text-transform: uppercase;
}
a.header-cart-contents {
color: inherit !important;
}
.header-cart-amount {

}
.header-cart-checkout {
margin: 0 0 0 4px;
font-size: 16px;
}





#main-menu {
text-align: center;
}
.main-navigation {
padding: 0;

-webkit-transition: right 0.4s ease 0s;
-moz-transition: right 0.4s ease 0s;
-ms-transition: right 0.4s ease 0s;
-o-transition: right 0.4s ease 0s;
transition: right 0.4s ease 0s;
}
.site-header-layout-one .main-navigation {
background-color: rgba(0, 0, 0, 1);
position: relative;
z-index: 4;
}
.site-header-layout-one .main-navigation li a {
padding: 18px 20px 18px;
}
.site-header-layout-one .main-navigation ul ul li a {
padding: 14px 25px 16px;
}
.main-navigation ul ul li {
position: relative;
}
.main-navigation ul ul ul {
}
.main-navigation ul li:hover > ul,
.main-navigation ul li.focus > ul {
right: auto;
left: 0;
}
.main-navigation ul ul li:hover > ul,
.main-navigation ul ul li.focus > ul {
right: auto;
left: 100%;
}

/* -------- Header Layout Two -------- */

.site-top-bar {
background-color: rgba(0, 0, 0, 0.6);
}
.site-top-bar-left {
float: left;
padding: 2px 0 0;
min-height: 31px;
}
.site-top-bar-right {
float: right;
padding: 2px 0 0;
min-height: 31px;
}
.site-header-layout-two {
}
.site-header-layout-two .header-social-icon {
margin: 0 10px 0 0;
}
.site-header-layout-two .site-topbar-right-no {
display: inline-block;
font-size: inherit;
vertical-align: middle;
margin: 0 12px 0 0;
padding: 0;
border: 0;
}
.site-header-layout-two .site-topbar-right-no span {
font-size: inherit;
}

.site-header-layout-two .main-navigation {
position: absolute;
bottom: 0;
right: 20px;
margin: 0;
}
.site-header-layout-two .main-navigation li {
margin: 0;
}
.site-header-layout-two .main-navigation li a {
padding: 55px 25px 60px;
}
.site-header-layout-two .main-navigation ul li:last-child a {
padding: 55px 0 60px 25px;
}

.site-header-layout-two .main-navigation ul ul li a {
padding: 14px 25px 16px !important;
}
.site-header-layout-two .main-navigation ul ul {
top: 130px;
border-top: 6px solid #000;
}
.site-header-layout-two .main-navigation ul ul ul {
top: 1px;
border: 0;
}

.sabino-header-nav {
display: inline-block;
vertical-align: middle;
margin: -1px 8px 0 0;
}
.sabino-header-nav ul {
margin: 0;
padding: 0;
}
.sabino-header-nav ul li {
display: inline-block;
vertical-align: middle;
list-style-type: none;
margin: 0;
padding: 0;
}
.sabino-header-nav ul li a {
display: block;
text-transform: uppercase;
padding: 0px 3px;
margin: 0 2px;
color: inherit;
}
.sabino-header-nav ul li:first-child a {
padding: 0px 3px 0 0;
margin: 0 2px 0 0;
}

body.show-site-search .search-block {
display: block;
}


/*--------------------------------------------------------------
# Infinite scroll
--------------------------------------------------------------*/
/* Globally hidden elements when Infinite Scroll is supported and in use. */
.infinite-scroll .posts-navigation, /* Older / Newer Posts Navigation (always hidden) */
.infinite-scroll.neverending .site-footer { /* Theme Footer (when set to scrolling) */
display: none;
}

/* When Infinite Scroll has reached its end we need to re-display elements that were hidden (via .neverending) before. */
.infinity-end.neverending .site-footer {
display: block;
}


/*--------------------------------------------------------------
## Galleries
--------------------------------------------------------------*/
.gallery {
margin-bottom: 1.5em;
}

.gallery-item {
display: inline-block;
text-align: center;
vertical-align: top;
width: 100%;
}

.gallery-columns-2 .gallery-item {
max-width: 50%;
}

.gallery-columns-3 .gallery-item {
max-width: 33.33%;
}

.gallery-columns-4 .gallery-item {
max-width: 25%;
}

.gallery-columns-5 .gallery-item {
max-width: 20%;
}

.gallery-columns-6 .gallery-item {
max-width: 16.66%;
}

.gallery-columns-7 .gallery-item {
max-width: 14.28%;
}

.gallery-columns-8 .gallery-item {
max-width: 12.5%;
}

.gallery-columns-9 .gallery-item {
max-width: 11.11%;
}

.gallery-caption {
display: block;
}

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

.menu-dropdown-btn {
display: block;
}
.header-menu-button {
display: block;
padding: 14px 0 16px;
text-transform: uppercase;
font-size: 17px;
cursor: pointer;
text-align: center;
}
.header-menu-button i {
font-size: 17px;
vertical-align: middle;
}
.header-menu-button span {
vertical-align: middle;
margin: 0 0 0 6px;
}
.site-header-layout-two .header-menu-button {
padding: 48px 0 60px 80px;
}

.main-navigation #main-menu {
color: #FFFFFF;
position: fixed;
top: 0;
right: -280px;
width: 280px;
max-width: 100%;
-ms-box-sizing: border-box;
box-sizing: border-box;
padding: 82px 22px 30px 22px;
background: #000000;
z-index: 99998;
height: 100%;
overflow: auto;
transition: right 0.4s ease 0s;
}
.main-navigation li {
display: block;
float: none;
}
.main-navigation li a {
display: block;
float: none;
padding: 8px 0 !important;
color: #C5C5C5 !important;
text-align: left;
}

.main-navigation ul ul {
position: relative !important;
top: 0 !important;
left: 0 !important;
float: none !important;
background-color: rgba(255, 255, 255, 0.14) !important;
padding: 0;
margin: 0;
display: none !important;
}
.main-navigation ul ul li:last-child a,
.main-navigation ul ul li a {
padding: 7px 10px;
width: auto;
}
.main-navigation ul ul li a {
background: none !important;
}

#primary-menu {
display: block;
}
.main-menu-close {
display: block;
border-radius: 4px;
position: absolute;
top: 10px;
right: 10px;
font-size: 30px;
color: #898989;
text-align: center;
padding: 0 8px 0 12px;
height: 40px;
line-height: 38px;
cursor: pointer;
z-index: 99;
}
.main-menu-close .fa-angle-left {
position: relative;
left: -4px;
}
li.open-page-item > ul.children,
li.open-page-item > ul.sub-menu {
display: block !important;
}

body.admin-bar .main-menu-close {
top: 52px;
}
body.admin-bar .header-cart {
top: 55px;
}

}

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

.post-loop-thumbnail {
float: none !important;
width: 100% !important;
}
.post-loop-content {
float: none !important;
width: 100% !important;
padding: 20px 5px 0 !important;
}

.content-layout-blocks .sabino-blog-breakup .post-loop-thumbnail {
position: relative !important;
height: 400px !important;
}
.content-layout-blocks .sabino-blog-breakup .post-loop-content {
margin: 0 !important;
padding: 20px !important;
}
.content-layout-blocks .sabino-blog-breakup .blog-top-layout .post-loop-thumbnail {
height: auto !important;
}

}

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

.page-template-default .content-area,
.woocommerce #container,
.woocommerce-page #container,
.content-area {
box-shadow: none;
width: 100%;
float: none;
padding: 25px 0 30px;
}
.content-layout-blocks.content-joined-widgets .content-area,
.content-layout-blocks.content-joined-widgets #container,
.content-layout-blocks.content-broken-widgets .content-area,
.content-layout-blocks.content-broken-widgets #container {
box-shadow: none;
width: 100%;
float: none !important;
padding: 25px 20px 30px;
}
.content-layout-blocks .site-container-main {
padding: 0 20px;
}

.page-template-default .widget-area,
.widget-area,
.content-layout-blocks.content-broken-widgets .widget-area {
box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.08);
width: 100%;
float: none;
padding: 0 0 5px !important;
margin: 0 0 10px;
}
.page-template-template-left-sidebar-php .content-area {
box-shadow: none;
width: 100%;
float: none;
padding: 25px 0 30px;
}
.page-template-template-left-sidebar-php .widget-area,
.page-template-template-left-sidebar-php .content-layout-blocks.content-broken-widgets .widget-area {
box-shadow: none;
width: 100%;
float: none;
padding: 0 0 5px;
margin: 0 0 10px;
}

/*--------------------------------------------------------------
Header One Styling
--------------------------------------------------------------*/
.site-branding {
float: none;
padding: 10px 0;
text-align: center;
}
.site-header-right {
position: relative;
margin: 0;
top: auto;
right: auto;
text-align: center;
}
.site-header-right-top {
min-height: initial;
}
.site-header-right-bottom {
padding: 0 0 5px;
}

.site-header-layout-two .main-navigation {
position: relative;
right: auto;
}
.site-header-layout-two .header-menu-button {
padding: 5px 0 15px;
}

.site-top-bar-left {
float: none;
text-align: center;
min-height: 20px;
}
.site-top-bar-right {
float: none;
text-align: center;
padding: 2px 0 2px;
}

.search-block {
position: relative;
top: 0 !important;
right: 0;
padding: 12px;
}
.search-block .search-field {
width: 100%;
}

.site-footer-standard .site-footer-widgets .site-container > ul {
display: block;
}
.site-footer-standard .site-footer-widgets .site-container > ul > li {
display: block;
width: 100%;
padding: 10px 0 20px !important;
}

.site-footer-bottom-bar-left,
.site-footer-bottom-bar-right {
float: none;
text-align: center;
}

}

body.show-main-menu #main-menu {
right: 0px !important;
}
body.show-main-menu #page {
right: 280px !important;
}

最佳答案

改变下面的类,减少填充

.site-header-layout-two .main-navigation li a {
padding: 19px 25px 6px;
}

并删除下面的代码

.site-header-layout-two .main-navigation ul li:last-child a {
padding: 55px 0 60px 25px;
}

关于css - 导航位置 "absolute"不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43189418/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com