如何摆脱下拉菜单上的额外空间?

时间:2016-05-12 13:33:29

标签: html css

所以我在悬停时创建了一个带有下拉菜单的导航栏,但问题是列表中的项目在左侧获得了一些额外的padding,而不是在哪里可以删除{ {1}}(我试过检查但找不到任何东西)。

这是问题所在: PROBLEM

这就是我想要的: HOW IT SHOULD BE

代码:

padding
@import url(https://fonts.googleapis.com/css?family=Raleway:600);
@import url(https://fonts.googleapis.com/css?family=Open+Sans:600);
@import url(https://fonts.googleapis.com/css?family=Roboto:400,500);
* {
    margin: 0px;
    border: 0px;
}


/*Header*/

header {
    position: relative;
    background-image: url(../img/forheader.png);
    background-size: cover;
}

.logo {
    background: rgba(224, 228, 40, 0.7);
    padding: 2.5%;
}

.logo img {
    position: relative;
    max-width: 35%;
}


/*Header Over*/


/* NAVIGATION */

nav {
    position: relative;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 60px;
    z-index: 100;
}

.unfixed {
    background-color: white;
    -webkit-transition: background-color 0.4s linear;
    transition: background-color 0.4s linear;
    box-shadow: 0px 5px 14px rgba(53, 53, 51, 0.12);
}

.fixed {
    background-color: hsla(152, 78%, 41%, 0.9);
    -webkit-transition: background-color 0.4s linear;
    transition: background-color 0.4s linear;
    box-shadow: 0px 5px 14px hsla(152, 78%, 41%, 0.54);
}

nav img {
    position: absolute;
    top: 5px;
    left: 5px;
    height: 50px;
    display: none;
}

ul {
    position: absolute;
    right: 3%;
    line-height: 60px;
    height: 60px;
}

ul li {
    display: inline-block;
    position: relative;
    height: 100%;
}

.unfixed ul li a {
    text-decoration: none;
    font-family: 'raleway';
    font-size: 24px;
    display: inline-block;
    padding-left: 15px;
    padding-right: 15px;
    color: black;
    box-sizing: border-box;
    font-weight: 700;
}

.unfixed ul li a::after {
    content: "";
    display: block;
    width: 0%;
    position: absolute;
    left: 50%;
    bottom: 15px;
    height: 1px;
    background: black;
    -webkit-transition: 0.3s linear all;
    transition: 0.3s linear all;
}

.unfixed ul li a:hover::after {
    width: calc(100% - 30px);
    left: 15px;
}

.fixed ul li a {
    text-decoration: none;
    font-family: 'raleway';
    font-size: 24px;
    display: inline-block;
    padding-left: 15px;
    padding-right: 15px;
    color: white;
    box-sizing: border-box;
    font-weight: 700;
}

.fixed ul li a::after {
    content: "";
    display: block;
    width: 0%;
    position: absolute;
    left: 50%;
    bottom: 15px;
    height: 1px;
    background: white;
    -webkit-transition: 0.3s linear all;
    transition: 0.3s linear all;
}

.fixed ul li a:hover::after {
    width: calc(100% - 30px);
    left: 15px;
}

/*DROP DOWN*/


nav ul li {
    position: relative;  
}

nav ul li ul {
     font-family: 'raleway';
     color: #fff; 
     font-size:24px;
     height: auto; 
     text-align:center;
     z-index:110;
     position: absolute; 
     left: 0; 
     right: 0; 
     top: 60px;
     -webkit-transform: scaleY(0);
     -webkit-transform-origin-Y: 0;
     -webkit-transition:all .5s;
}
.unfixed ul li ul{ 
    width: 150px; 
    background: rgba(228, 228, 228, 0.87); 
    box-shadow: 0px 5px 14px  hsla(152, 1%, 67%, 0.54);
}
.fixed ul li ul{
    background-color: hsla(152, 78%, 41%, 0.9);
    width:150px;
    box-shadow:0px 5px 14px hsla(152, 78%, 41%, 0.54)
}

nav ul li:hover ul {
     -webkit-transform: scaleY(1);
    
}



/*NAVIGATION OVER*/
/*FOOTER*/

/*FOOTER*/

footer {
    position: relative;
    background: rgba(28, 29, 38, 0.95);
    color: white;
    font-family: 'Open Sans', sans-serif;
    padding: 30px;
    font-size: 13px;
    text-align: center;
}

footer h3 {
    margin: 5px;
}

footer .social {
    font-size: 17px;
}

footer .social img {
    width: 40px;
    height: 40px;
    margin: 10px;
    -webkit-transition: 0.4s linear all;
    transition: 0.4s linear all;
    -webkit-filter: saturate(0);
    -moz-filter: saturate(0);
    -o-filter: saturate(0);
    -ms-filter: saturate(0);
    filter: saturate(0);
}

footer .social img:hover {
    -webkit-filter: saturate(1);
    -moz-filter: saturate(1);
    -o-filter: saturate(1);
    -ms-filter: saturate(1);
    filter: saturate(1);
}

/*FOOTER OVER*/
/* SCROLL BAR AND SELECTION */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background: #444;
}

::-webkit-scrollbar-track {
    background: #FFF;
    -webkit-box-shadow: inset 1px 1px 2px #E0E0E0;
    border: 1px solid #D8D8D8;
}

::-moz-selection {
  color: white;
  background: #f01943;
}

::selection {
  color: white;
  background: #f01943;
}

@media screen and (max-width:850px) {
     .fixed ul li a {
    text-decoration: none;
    font-family: 'raleway';
    font-size: 18px;
    display: inline-block;
    padding-left: 10px;
    padding-right: 10px;
    color: white;
    box-sizing: border-box;
    font-weight: 700;
}
.unfixed ul li a {
    text-decoration: none;
    font-family: 'raleway';
    font-size: 18px;
    display: inline-block;
    padding-left: 10px;
    padding-right: 10px;
    color: black;
    box-sizing: border-box;
    font-weight: 700;
}
nav img {
    position: absolute;
    top: 5px;
    left: 5px;
    height: 0;
        display: none;
}

}

2 个答案:

答案 0 :(得分:1)

class WidgetLogger(logging.Handler): def __init__(self, widget): logging.Handler.__init__(self) self.setLevel(logging.DEBUG) self.widget = widget self.widget.config(state='disabled') self.widget.tag_config("INFO", foreground="black") self.widget.tag_config("DEBUG", foreground="grey") self.widget.tag_config("WARNING", foreground="orange") self.widget.tag_config("ERROR", foreground="red") self.widget.tag_config("CRITICAL", foreground="red", underline=1) self.red = self.widget.tag_configure("red", foreground="red") def emit(self, record): self.widget.config(state='normal') # Append message (record) to the widget self.widget.insert(tk.END, self.format(record) + '\n', record.levelname) self.widget.see(tk.END) # Scroll to the bottom self.widget.config(state='disabled') self.widget.update() # Refresh the widget 默认为ul,因此只需将padding添加到padding:0

即可重置

备注

nav ul li ul已弃用,因此使用

<center>
@import url(https://fonts.googleapis.com/css?family=Raleway:600);
@import url(https://fonts.googleapis.com/css?family=Open+Sans:600);
@import url(https://fonts.googleapis.com/css?family=Roboto:400,500);
 * {
  margin: 0px;
  border: 0px;
}
/*Header*/

header {
  position: relative;
  background-image: url(../img/forheader.png);
  background-size: cover;
}
.logo {
  background: rgba(224, 228, 40, 0.7);
  padding: 2.5%;
}
.logo img {
  position: relative;
  max-width: 35%;
}
/*Header Over*/

/* NAVIGATION */

nav {
  position: relative;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 60px;
  z-index: 100;
}
.unfixed {
  background-color: white;
  -webkit-transition: background-color 0.4s linear;
  transition: background-color 0.4s linear;
  box-shadow: 0px 5px 14px rgba(53, 53, 51, 0.12);
}
.fixed {
  background-color: hsla(152, 78%, 41%, 0.9);
  -webkit-transition: background-color 0.4s linear;
  transition: background-color 0.4s linear;
  box-shadow: 0px 5px 14px hsla(152, 78%, 41%, 0.54);
}
nav img {
  position: absolute;
  top: 5px;
  left: 5px;
  height: 50px;
  display: none;
}
ul {
  position: absolute;
  right: 3%;
  line-height: 60px;
  height: 60px;
}
ul li {
  display: inline-block;
  position: relative;
  height: 100%;
}
.unfixed ul li a {
  text-decoration: none;
  font-family: 'raleway';
  font-size: 24px;
  display: inline-block;
  padding-left: 15px;
  padding-right: 15px;
  color: black;
  box-sizing: border-box;
  font-weight: 700;
}
.unfixed ul li a::after {
  content: "";
  display: block;
  width: 0%;
  position: absolute;
  left: 50%;
  bottom: 15px;
  height: 1px;
  background: black;
  -webkit-transition: 0.3s linear all;
  transition: 0.3s linear all;
}
.unfixed ul li a:hover::after {
  width: calc(100% - 30px);
  left: 15px;
}
.fixed ul li a {
  text-decoration: none;
  font-family: 'raleway';
  font-size: 24px;
  display: inline-block;
  padding-left: 15px;
  padding-right: 15px;
  color: white;
  box-sizing: border-box;
  font-weight: 700;
}
.fixed ul li a::after {
  content: "";
  display: block;
  width: 0%;
  position: absolute;
  left: 50%;
  bottom: 15px;
  height: 1px;
  background: white;
  -webkit-transition: 0.3s linear all;
  transition: 0.3s linear all;
}
.fixed ul li a:hover::after {
  width: calc(100% - 30px);
  left: 15px;
}
/*DROP DOWN*/

nav ul li {
  position: relative;
}
nav ul li ul {
  font-family: 'raleway';
  color: #fff;
  font-size: 24px;
  height: auto;
  text-align: center;
  z-index: 110;
  position: absolute;
  left: 0;
  right: 0;
  top: 60px;
  -webkit-transform: scaleY(0);
  -webkit-transform-origin-Y: 0;
  -webkit-transition: all .5s;
  padding: 0
}
.unfixed ul li ul {
  width: 150px;
  background: rgba(228, 228, 228, 0.87);
  box-shadow: 0px 5px 14px hsla(152, 1%, 67%, 0.54);
}
.fixed ul li ul {
  background-color: hsla(152, 78%, 41%, 0.9);
  width: 150px;
  box-shadow: 0px 5px 14px hsla(152, 78%, 41%, 0.54)
}
nav ul li:hover ul {
  -webkit-transform: scaleY(1);
}
/*NAVIGATION OVER*/

/*FOOTER*/

/*FOOTER*/

footer {
  position: relative;
  background: rgba(28, 29, 38, 0.95);
  color: white;
  font-family: 'Open Sans', sans-serif;
  padding: 30px;
  font-size: 13px;
  text-align: center;
}
footer h3 {
  margin: 5px;
}
footer .social {
  font-size: 17px;
}
footer .social img {
  width: 40px;
  height: 40px;
  margin: 10px;
  -webkit-transition: 0.4s linear all;
  transition: 0.4s linear all;
  -webkit-filter: saturate(0);
  -moz-filter: saturate(0);
  -o-filter: saturate(0);
  -ms-filter: saturate(0);
  filter: saturate(0);
}
footer .social img:hover {
  -webkit-filter: saturate(1);
  -moz-filter: saturate(1);
  -o-filter: saturate(1);
  -ms-filter: saturate(1);
  filter: saturate(1);
}
/*FOOTER OVER*/

/* SCROLL BAR AND SELECTION */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: #444;
}
::-webkit-scrollbar-track {
  background: #FFF;
  -webkit-box-shadow: inset 1px 1px 2px #E0E0E0;
  border: 1px solid #D8D8D8;
}
::-moz-selection {
  color: white;
  background: #f01943;
}
::selection {
  color: white;
  background: #f01943;
}
@media screen and (max-width: 850px) {
  .fixed ul li a {
    text-decoration: none;
    font-family: 'raleway';
    font-size: 18px;
    display: inline-block;
    padding-left: 10px;
    padding-right: 10px;
    color: white;
    box-sizing: border-box;
    font-weight: 700;
  }
  .unfixed ul li a {
    text-decoration: none;
    font-family: 'raleway';
    font-size: 18px;
    display: inline-block;
    padding-left: 10px;
    padding-right: 10px;
    color: black;
    box-sizing: border-box;
    font-weight: 700;
  }
  nav img {
    position: absolute;
    top: 5px;
    left: 5px;
    height: 0;
    display: none;
  }
}

答案 1 :(得分:0)

只需在样式表中添加.unfixed ul {padding-left:0;}即可从下拉菜单左侧删除默认的40px填充。