Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 对中响应菜单_Jquery_Html_Css - Fatal编程技术网

Jquery 对中响应菜单

Jquery 对中响应菜单,jquery,html,css,Jquery,Html,Css,我正在制作响应性的水平菜单,在向下滚动时在后台淡出(使用jQuery实现) 所以我尝试将菜单居中,但失败了,我使用了width:50%,但它不会将菜单居中 .container { width: 100%; height: 2000px; position: relative; font-family: 'Trebuchet Ms'; } .bg { background: #000; width: 100%; height: 100px; opacity: 0

我正在制作响应性的水平菜单,在向下滚动时在后台淡出(使用jQuery实现)

所以我尝试将菜单居中,但失败了,我使用了
width:50%,但它不会将菜单居中

.container {
  width: 100%;
  height: 2000px;
  position: relative;
  font-family: 'Trebuchet Ms';
}

.bg {
  background: #000;
  width: 100%;
  height: 100px;
  opacity: 0;
}

.show {
  opacity: 0.4;
}

.transition {    
  -webkit-transition: all 1s ease-in-out;
    -moz-transition: all 1s ease-in-out;
    -o-transition: all 1s ease-in-out;
    transition: all 1s ease-in-out;
}

.fixed {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1;
}

ul {
  height: 200px;
  margin: -70px 0 0;
  width: 50%;
}

li {
  direction: rtl;
  float: right; 
  list-style: none;
  padding-right: 30px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #000;
}

a {
  text-align: center;
  font-size: 50px;
  color: #bdbdbd;
  font-weight: bold;
  text-decoration: none;
  letter-spacing: 5px;
  text-shadow: 1px 1px 1px #949494;

  position: relative;
  z-index: 1;
  margin: 0 auto;
  display: block;
}

a:hover {
  color: #a6a6a6;
  text-shadow: 1px 1px 1px #C9C9C9;
}

.down {
  top: 150px;
}

.up {
  top: 1800px;
}
HTML:


  • אוות
  • 什么
  • 吃什么
  • צורקשר
  • 获取应用程序


如何以响应方式居中菜单?

目前还没有任何特定的居中元素样式。试一试


保证金:0自动

对于居中元素还没有任何特定的样式。试一试


保证金:0自动

我通常使用Flexbox将项目居中。使包含的div显示为:flex,然后可以对齐内容并使其与中心对齐

我通常使用Flexbox将项目居中。使包含的div显示为:flex,然后可以对齐内容并使其与中心对齐

试试这个:
文本对齐:居中
边距:0自动用于UL菜单

.fixed {
  position: fixed;
  top: 0;
  left: 0;
  right:0;
  width: 100%;
  z-index: 1;
text-align:center;
}

ul {
  height: 200px;
  margin: -70px auto 0 auto;
  width: 50%;
}

试试这个:
文本对齐:居中
边距:0自动用于UL菜单

.fixed {
  position: fixed;
  top: 0;
  left: 0;
  right:0;
  width: 100%;
  z-index: 1;
text-align:center;
}

ul {
  height: 200px;
  margin: -70px auto 0 auto;
  width: 50%;
}

尝试在ul上使用flex和justify content:center


尝试在ul上使用flex,并将其与内容:中心对齐


的可能副本的可能副本我已经试过了,但不起作用。有些东西阻止了自动保证金的正常工作。在你的JS提琴中它对我起作用,所以我不确定哪一部分不是你想要的。我把保证金自动放在ul元素上。由于宽度为50%,您的某些li元素可能会下降到下面的行,但您可以通过增加ul的宽度来解决此问题。如果我遗漏了什么,请告诉我。我已经试过了,但不起作用。有些东西阻止了自动保证金的正常工作。在你的JS提琴中它对我起作用,所以我不确定哪一部分不是你想要的。我把保证金自动放在ul元素上。由于宽度为50%,您的某些li元素可能会下降到下面的行,但您可以通过增加ul的宽度来解决此问题。如果我遗漏了什么,请告诉我。仍然不起作用,它的航向比中心偏右仍然不起作用,它的航向比中心偏右
ul {
  height: 200px;
  margin: -70px 0 0;
  width: 50%;
}
ul {
  height: 200px;
  display:flex;
  justify-content: center;
}