0

Добавил меню оно у меня какое то корявое, слова не отображаются прямо по центру. А слово "О нас" так вообще одна буква "О" только отображается. Как можно исправить ошибку.

введите сюда описание изображения

CSS

html, body {
    background: #fff;
    font: 100% helvetica, arial, sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#container {            
    margin: 40px auto;
    width: 800px;    
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
}

#header {
    border-bottom: 1px solid #eee;            
    margin: 0 0 20px;
    overflow: hidden;
    padding: 0 0 10px;
}



a {
    color: #111;
    font-weight: bold;
    text-decoration: none;
    -moz-transition: all 300ms ease-out;
    -webkit-transition: all 300ms ease-out; 
    -ms-transition: all 300ms ease-out; 
    transition: all 300ms ease-out;
}

a:hover {
    color: #555;    
}

/*============================*/
/* Main Navigation
/*============================*/
#nav {            
    height: 50px;
    line-height: 50px;            
    width: 100%;
    text-align: center;
}

#nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: inline-block;
}

#nav li {    
    background: #333;
    background-image: -o-linear-gradient(bottom, #222222 0%, #555555 100%);
    background-image: -moz-linear-gradient(bottom, #222222 0%, #555555 100%);
    background-image: -webkit-linear-gradient(bottom, #222222 0%, #555555 100%);
    background-image: -ms-linear-gradient(bottom, #222222 0%, #555555 100%);    
    background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #222222),color-stop(1, #555555));    
    background-image: linear-gradient(bottom, #222222 0%, #555555 100%);
    float: left;
    position: relative;
    width: 20%;    
}

#nav li:first-child, #nav li:first-child a { 
    -webkit-border-radius: 3px 0 0 3px; 
    -moz-border-radius: 3px 0 0 3px; 
    border-radius: 3px 0 0 3px; 
}
#nav li:last-child, #nav li:last-child a { 
    -webkit-border-radius: 0 3px 3px 0; 
    -moz-border-radius: 0 3px 3px 0; 
    border-radius: 0 3px 3px 0; 
}

#nav a {                
    border-right: 1px solid #222;
    border-left: 1px solid #555;
    color: #ccc;
    display: block;
    font-size: 14px;
    height: 50px;
    overflow: hidden;
    text-align: center;
    text-shadow: 0 -1px 0 #000;    
    -webkit-box-shadow: inset 0 0 10px transparent;
    -moz-box-shadow: inset 0 0 10px transparent;
    padding: 0 60px;
}

#nav a:after {
    background: rgba(255,255,255,.07);
    content: "";
    height: 25px;
    left: 0;
    position: absolute;
    width: 100%;
}

#nav li:hover > a {
    background: #333;
    border-left-color: #222;
    color: #fff;
    text-shadow: 0 1px 0 #000;
    -webkit-box-shadow: inset 0 0 10px #111;
    -moz-box-shadow: inset 0 0 10px #111;
    box-shadow: inset 0 0 10px #111;
}
#nav span {
    position: relative;    
}

#nav a:active span {
    color: #ffd;
    position: relative;
    top: 1px;
}

#nav li:first-child a {
    border-left: none;    
}

#nav li:last-child a {
    border-right: none;    
}

.dropdown > a span:after {
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 5px solid #ccc;
    content: "";
    right: -13px;
    position: absolute;
    top: 3px;
}

.dropdown:hover > a span:after {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #fff;
    content: "";
    right: -15px;
    position: absolute;
    top: 6px;
}

/*============================*/
/* Sub Navigation
/*============================*/
#nav ul ul {
    opacity: 0;
    position: absolute;
    top: 50px;
    visibility: hidden;
    width: 0;
    -moz-transition: all 300ms ease-out;
    -webkit-transition: all 300ms ease-out; 
    -ms-transition: all 300ms ease-out; 
    transition: all 300ms ease-out;
    left: 0;
}

#nav ul li:hover ul {
    opacity: 1;
    visibility: visible;
    width: 100%;
}

#nav ul ul li {
    background: #f3f3f3;
    float: none;    
    line-height: 0;
    width: 100%;            
}

#nav ul ul li:nth-child(odd) {
    background: #eee;    
}

#nav ul ul li:first-child, #nav ul ul li:first-child a { 
    -webkit-border-radius: 0; 
    -moz-border-radius: 0; 
    border-radius: 0; 
}
#nav ul ul li:last-child, #nav ul ul li:last-child a { 
    -webkit-border-radius: 0 0 3px 3px; 
    -moz-border-radius: 0 0 3px 3px; 
    border-radius: 0 0 3px 3px; 
}

#nav ul ul li a {
    border-right: none;
    border-left: none;
    border-top: 1px solid #fff;
    color: #555;
    font-size: 12px;
    height: 36px;
    line-height: 36px;
    padding: 0 0 0 15px;
    text-align: left;
    text-shadow: 0 -1px 0 #eee;
}

#nav ul li ul li a:after {
    background: rgba(0,0,0,.02);
    content: "";
    height: 18px;
    left: 0;
    position: absolute;
    top: 19px;
    width: 100%;
}

#nav ul ul li a:hover {
    background: #ffd;
    color: #111;
    text-shadow: 0 1px 0 #fff;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
}

#nav ul ul a:active span {
    color: #111;
    position: relative;
    top: 1px;
}

.it{
  width:50%;
  margin:auto;
}


.add{
   width:600px;
  margin: 0 auto;
}

* { box-sizing: border-box; }

HTML

  <div id="container">
    <div id="header">


    </div>
    <div id="nav">
        <ul>
            <li><a href="${pageContext.request.contextPath}/"><span>Главная</span></a></li>

            <li class="dropdown"><a href="${pageContext.request.contextPath}/allStudents"><span>Студенты</span></a>
                <ul>
                    <li><a href="${pageContext.request.contextPath}/allStudents"><span>Список студентов</span></a></li>
                    <sec:authorize access="hasRole('ADMIN') || hasRole('USER')">
                    <li><a href="${pageContext.request.contextPath}/addStudent"><span>Добавить студента</span></a></li>
                    </sec:authorize>
                </ul>
            </li>
            <li><a><span>О нас </span></a></li> 
            <sec:authorize access="!isAuthenticated()"> 
            <li><a href="${pageContext.request.contextPath}/logout"><span>Выйти</span></a></li>
             </sec:authorize>
        </ul>
    </div>
</div>

        <sitemesh:write property='body'/>
    <jsp:include page="/WEB-INF/template/admintemplate.jsp"/>  
    </body>

1 ответ 1

1

для #nav li используете width:20% и padding:0 60px, что вызывает смещение текста в блоке и сдвиг соответственно (потому как не хватает ширины разместить текст как вам необходимо).

Вот примерная реализация без width:20%:

html,
body {
  background: #fff;
  font: 100% helvetica, arial, sans-serif;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#container {
  margin: 40px auto;
  width: 800px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}

#header {
  border-bottom: 1px solid #eee;
  margin: 0 0 20px;
  overflow: hidden;
  padding: 0 0 10px;
}

a {
  color: #111;
  font-weight: bold;
  text-decoration: none;
  -moz-transition: all 300ms ease-out;
  -webkit-transition: all 300ms ease-out;
  -ms-transition: all 300ms ease-out;
  transition: all 300ms ease-out;
}

a:hover {
  color: #555;
}


/*============================*/


/* Main Navigation
        /*============================*/

#nav {
  height: 50px;
  line-height: 50px;
  width: 100%;
  text-align: center;
}

#nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: inline-block;
}

#nav li {
  background: #333;
  background-image: -o-linear-gradient(bottom, #222222 0%, #555555 100%);
  background-image: -moz-linear-gradient(bottom, #222222 0%, #555555 100%);
  background-image: -webkit-linear-gradient(bottom, #222222 0%, #555555 100%);
  background-image: -ms-linear-gradient(bottom, #222222 0%, #555555 100%);
  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #222222), color-stop(1, #555555));
  background-image: linear-gradient(bottom, #222222 0%, #555555 100%);
  float: left;
  position: relative;
  /* width: 20%;*/
}

#nav li:first-child,
#nav li:first-child a {
  -webkit-border-radius: 3px 0 0 3px;
  -moz-border-radius: 3px 0 0 3px;
  border-radius: 3px 0 0 3px;
}

#nav li:last-child,
#nav li:last-child a {
  -webkit-border-radius: 0 3px 3px 0;
  -moz-border-radius: 0 3px 3px 0;
  border-radius: 0 3px 3px 0;
}

#nav a {
  border-right: 1px solid #222;
  border-left: 1px solid #555;
  color: #ccc;
  display: block;
  font-size: 14px;
  height: 50px;
  overflow: hidden;
  text-align: center;
  text-shadow: 0 -1px 0 #000;
  -webkit-box-shadow: inset 0 0 10px transparent;
  -moz-box-shadow: inset 0 0 10px transparent;
  padding: 0 60px;
}

#nav a:after {
  background: rgba(255, 255, 255, .07);
  content: "";
  height: 25px;
  left: 0;
  position: absolute;
  width: 100%;
}

#nav li:hover>a {
  background: #333;
  border-left-color: #222;
  color: #fff;
  text-shadow: 0 1px 0 #000;
  -webkit-box-shadow: inset 0 0 10px #111;
  -moz-box-shadow: inset 0 0 10px #111;
  box-shadow: inset 0 0 10px #111;
}

#nav span {
  position: relative;
}

#nav a:active span {
  color: #ffd;
  position: relative;
  top: 1px;
}

#nav li:first-child a {
  border-left: none;
}

#nav li:last-child a {
  border-right: none;
}

.dropdown>a span:after {
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 5px solid #ccc;
  content: "";
  right: -13px;
  position: absolute;
  top: 3px;
}

.dropdown:hover>a span:after {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #fff;
  content: "";
  right: -15px;
  position: absolute;
  top: 6px;
}


/*============================*/


/* Sub Navigation
        /*============================*/

#nav ul ul {
  opacity: 0;
  position: absolute;
  top: 50px;
  visibility: hidden;
  width: 0;
  -moz-transition: all 300ms ease-out;
  -webkit-transition: all 300ms ease-out;
  -ms-transition: all 300ms ease-out;
  transition: all 300ms ease-out;
  left: 0;
}

#nav ul li:hover ul {
  opacity: 1;
  visibility: visible;
  width: 100%;
}

#nav ul ul li {
  background: #f3f3f3;
  float: none;
  line-height: 0;
  width: 100%;
}

#nav ul ul li:nth-child(odd) {
  background: #eee;
}

#nav ul ul li:first-child,
#nav ul ul li:first-child a {
  -webkit-border-radius: 0;
  -moz-border-radius: 0;
  border-radius: 0;
}

#nav ul ul li:last-child,
#nav ul ul li:last-child a {
  -webkit-border-radius: 0 0 3px 3px;
  -moz-border-radius: 0 0 3px 3px;
  border-radius: 0 0 3px 3px;
}

#nav ul ul li a {
  border-right: none;
  border-left: none;
  border-top: 1px solid #fff;
  color: #555;
  font-size: 12px;
  height: 36px;
  line-height: 36px;
  padding: 0 0 0 15px;
  text-align: left;
  text-shadow: 0 -1px 0 #eee;
}

#nav ul li ul li a:after {
  background: rgba(0, 0, 0, .02);
  content: "";
  height: 18px;
  left: 0;
  position: absolute;
  top: 19px;
  width: 100%;
}

#nav ul ul li a:hover {
  background: #ffd;
  color: #111;
  text-shadow: 0 1px 0 #fff;
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none;
}

#nav ul ul a:active span {
  color: #111;
  position: relative;
  top: 1px;
}

.it {
  width: 50%;
  margin: auto;
}

.add {
  width: 600px;
  margin: 0 auto;
}

* {
  box-sizing: border-box;
}
<div id="container">
  <div id="header">


  </div>
  <div id="nav">
    <ul>
      <li><a href="${pageContext.request.contextPath}/"><span>Главная</span></a></li>

      <li class="dropdown"><a href="${pageContext.request.contextPath}/allStudents"><span>Студенты</span></a>
        <ul>
          <li><a href="${pageContext.request.contextPath}/allStudents"><span>Список студентов</span></a></li>
          <sec:authorize access="hasRole('ADMIN') || hasRole('USER')">
            <li><a href="${pageContext.request.contextPath}/addStudent"><span>Добавить студента</span></a></li>
          </sec:authorize>
        </ul>
      </li>
      <li><a><span>О нас </span></a></li>
      <sec:authorize access="!isAuthenticated()">
        <li><a href="${pageContext.request.contextPath}/logout"><span>Выйти</span></a></li>
      </sec:authorize>
    </ul>
  </div>
</div>

<sitemesh:write property='body' />
<jsp:include page="/WEB-INF/template/admintemplate.jsp" />
</body>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.