2016-10-03 1 views
0

요소 상태가 focus과 관련되어 있는지 확실하지 않지만 .nav-pills (아래 예 참조) 중 하나를 클릭하면 마우스를 움직여도 .active이됩니다 내가 페이지의 다른 곳을 클릭 할 때까지 Google 크롬 웹 검사기에서는이 사실을 알 수 없습니다. 첫 번째 약을 내 페이지에서 유일한 활성 약으로하고 싶습니다. BS .nav-pills stay depressed

죄송합니다

/* Primary Syle Sheet */ 
 

 
/* Basic Typography */ 
 

 
#topnav { 
 
\t margin-bottom: 30px; 
 
} 
 

 
#topnav .nav-pills > li { 
 
\t margin-left: 11px; 
 
\t margin-right: 11px; 
 
\t text-size: 100px; 
 
} 
 

 
#topnav>.nav-pills>li>a { 
 
\t padding-top: 11px; 
 
\t padding-bottom: 11px; 
 
\t font-size: 24px; 
 
\t color: #333; 
 
} 
 

 
#topnav>.nav-pills>li.active>a, #topnav>.nav-pills>li>a:hover { 
 
\t background-color: #eee; 
 
} 
 

 
.nav-pills>li>a:hover { 
 
\t opacity: 0.7; 
 
} 
 

 
#navbar-nav>li>a { 
 
    padding-top: 10px; 
 
    padding-bottom: 10px; 
 
    line-height: 20px; 
 
} 
 

 
@media (min-width: 768px) { 
 
\t #navbar-nav>li>a { 
 
    \t padding-top: 15px; 
 
    \t padding-bottom: 15px; 
 
    \t margin-top: 3px; 
 
    \t margin-bottom: 3px; 
 
    } 
 
    #navbar-nav { 
 
    \t width: 100%; 
 
    \t text-align: center !important; 
 
    \t } 
 
    \t #navbar-nav > li { 
 
     \t float: none; 
 
     \t display: inline-block; 
 
    } 
 
} 
 

 
.center-pills { 
 
\t display: inline-block; 
 
} 
 

 
.h1 small.sbttl, .h2 small.sbttl, .h3 small.sbttl, .h4 small.sbttl, .h5 small.sbttl, .h6 small.sbttl, h1 small.sbttl, h2 small.sbttl, h3 small.sbttl, h4 small.sbttl, h5 small.sbttl, h6 small.sbttl { 
 
\t display: block; 
 
\t font-size: 33%; 
 
\t color: inherit !important; 
 
\t opacity: 0.75; 
 
} 
 

 
/* Targeted Stylings */ 
 

 
header { 
 
    background-color: yellow; 
 
    background-repeat: no-repeat; 
 
    background-attachment: scroll; 
 
    background-position: center center; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    background-size: cover; 
 
    -o-background-size: cover; 
 
    text-align: center; 
 
    color: #fff !important; 
 
} 
 

 
@media (min-width: 768px) { 
 
\t header .brand-name { 
 
    \t padding-top: 200px !important; 
 
    \t padding-bottom: 200px !important; 
 
\t } 
 
} 
 

 
header .brand-name { 
 
    padding-top: 100px; 
 
    padding-bottom: 100px; 
 
} 
 

 
header .brand-name h1 { 
 
\t font-size: 75px; 
 
\t font-style: italic; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<!DOCTYPE html> 
 
<html lang="en"> 
 
    <head> 
 
    <meta charset="utf-8"> 
 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 
 
    <title>Example</title> 
 
    
 
    <!-- Primary Stylesheets --> 
 
    <link href="css/styles_1.css" rel="stylesheet"> 
 

 
    <!-- Bootstrap --> 
 
    <!-- Latest compiled and minified CSS --> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 

 
    <!-- Optional theme --> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> 
 

 
    <!-- Latest compiled and minified JavaScript --> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 
 

 
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 
 
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
 
    <!--[if lt IE 9]> 
 
     <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> 
 
     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
 
    <![endif]--> 
 
    </head> 
 
    <body id="page-top" class="index"> 
 
    \t <header> 
 
    \t \t <div class="container"> 
 
    \t \t \t <div class="brand-name"> 
 
    \t \t \t \t <h1>Title <small class="sbttl">Subtitle</small></h1> 
 
    \t \t \t </div> 
 
    \t \t 
 
    \t \t \t <!-- Initial --> 
 
    \t \t \t <div class="container text-center" id="topnav"> 
 
    \t \t \t \t <ul class="nav nav-pills center-pills"> 
 
    \t \t \t \t \t <li role="presentation" class="active"><a href="#">content</a></li> 
 
    \t \t \t \t \t <li role="presentation"><a href="#">content</a></li> 
 
    \t \t \t \t \t <li role="presentation"><a href="#">content</a></li> 
 
    \t \t \t \t \t <li role="presentation"><a href="#">content</a></li> 
 
\t \t \t \t </ul> 
 
    \t \t \t </div> 
 
    \t \t </div> 
 
    \t </header> 
 

 
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
    <!-- Include all compiled plugins (below), or include individual files as needed --> 
 
    </body> 
 
</html>
내 조각에 너무 많이 포함 한 경우

, 내가 스택 오버플로에 새로 온 사람.

답변

0

active 수정자는 항상 지정된 버튼을 활성화 상태로 만듭니다. 귀하의 예제에서 당신은 정확히 그것을 완료했습니다, 당신은 단지 hover 수정자를보고 있습니다.

(css)으로 변경할 수 있습니다.

+0

그래서 ... 내가 필요로하는 페이지의 다른 곳을 클릭 할 때까지 그 상태에 머물러 있지 않습니까? – jajaperson

+0

CSS의 'li : hover'에서 모든 것을 지우고 싶거나'li : hover {color : black; } '또는 무엇이든 디자인에 가장 적합합니다. – mark

+0

하지만 실제로 마우스를 가리키면 마우스를 가리킬 수 없습니다. 또한 알약의 색이 먹는 피임약의 색상과 ': 호버'와 일치하지 않기 때문에이 해결책이 맞는지 확실하지 않습니다 – jajaperson

0

/* Primary Syle Sheet */ 
 

 
/* Basic Typography */ 
 

 
#topnav { 
 
\t margin-bottom: 30px; 
 
} 
 

 
#topnav .nav-pills > li { 
 
\t margin-left: 11px; 
 
\t margin-right: 11px; 
 
\t text-size: 100px; 
 
} 
 

 
#topnav>.nav-pills>li>a { 
 
\t padding-top: 11px; 
 
\t padding-bottom: 11px; 
 
\t font-size: 24px; 
 
\t color: #333; 
 
} 
 

 
#topnav>.nav-pills>li.active>a, #topnav>.nav-pills>li>a:hover { 
 
\t background-color: #eee; 
 
} 
 

 
.nav-pills>li>a:hover { 
 
\t opacity: 0.7; 
 
} 
 

 
#navbar-nav>li>a { 
 
    padding-top: 10px; 
 
    padding-bottom: 10px; 
 
    line-height: 20px; 
 
} 
 

 
@media (min-width: 768px) { 
 
\t #navbar-nav>li>a { 
 
    \t padding-top: 15px; 
 
    \t padding-bottom: 15px; 
 
    \t margin-top: 3px; 
 
    \t margin-bottom: 3px; 
 
    } 
 
    #navbar-nav { 
 
    \t width: 100%; 
 
    \t text-align: center !important; 
 
    \t } 
 
    \t #navbar-nav > li { 
 
     \t float: none; 
 
     \t display: inline-block; 
 
    } 
 
} 
 

 
.center-pills { 
 
\t display: inline-block; 
 
} 
 

 
.h1 small.sbttl, .h2 small.sbttl, .h3 small.sbttl, .h4 small.sbttl, .h5 small.sbttl, .h6 small.sbttl, h1 small.sbttl, h2 small.sbttl, h3 small.sbttl, h4 small.sbttl, h5 small.sbttl, h6 small.sbttl { 
 
\t display: block; 
 
\t font-size: 33%; 
 
\t color: inherit !important; 
 
\t opacity: 0.75; 
 
} 
 

 
/* Targeted Stylings */ 
 

 
header { 
 
    background-color: yellow; 
 
    background-repeat: no-repeat; 
 
    background-attachment: scroll; 
 
    background-position: center center; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    background-size: cover; 
 
    -o-background-size: cover; 
 
    text-align: center; 
 
    color: #fff !important; 
 
} 
 

 
@media (min-width: 768px) { 
 
\t header .brand-name { 
 
    \t padding-top: 200px !important; 
 
    \t padding-bottom: 200px !important; 
 
\t } 
 
} 
 

 
header .brand-name { 
 
    padding-top: 100px; 
 
    padding-bottom: 100px; 
 
} 
 

 
header .brand-name h1 { 
 
\t font-size: 75px; 
 
\t font-style: italic; 
 
}
<!DOCTYPE html> 
 
<html lang="en"> 
 
    <head> 
 
    <meta charset="utf-8"> 
 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 
 
    <title>Example</title> 
 
    
 
    
 

 
    <!-- Bootstrap --> 
 
    <!-- Latest compiled and minified CSS --> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 
<!-- Primary Stylesheets --> 
 
    <link href="css/styles_1.css" rel="stylesheet"> 
 

 
    <!-- Optional theme --> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> 
 
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
    <!-- Include all compiled plugins (below), or include individual files as needed --> 
 
    <!-- Latest compiled and minified JavaScript --> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 
 

 
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 
 
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
 
    <!--[if lt IE 9]> 
 
     <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> 
 
     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
 
    <![endif]--> 
 
    </head> 
 
    <body id="page-top" class="index"> 
 
    \t <header> 
 
    \t \t <div class="container"> 
 
    \t \t \t <div class="brand-name"> 
 
    \t \t \t \t <h1>Title <small class="sbttl">Subtitle</small></h1> 
 
    \t \t \t </div> 
 
    \t \t 
 
    \t \t \t <!-- Initial --> 
 
    \t \t \t <div class="container text-center" id="topnav"> 
 
    \t \t \t \t <ul class="nav nav-pills center-pills"> 
 
    \t \t \t \t \t <li role="presentation" class="active"><a href="#" data-toggle="pill">content</a></li> 
 
    \t \t \t \t \t <li role="presentation"><a data-toggle="pill" href="#">content</a></li> 
 
    \t \t \t \t \t <li role="presentation"><a data-toggle="pill" href="#">content</a></li> 
 
    \t \t \t \t \t <li role="presentation"><a data-toggle="pill" href="#">content</a></li> 
 
\t \t \t \t </ul> 
 
    \t \t \t </div> 
 
    \t \t </div> 
 
    \t </header> 
 

 
    
 
    </body> 
 
</html>

안녕하세요, 당신은

+0

도움을 주셔서 감사합니다. 그러나 해결책이 도움이되지 않습니다. – jajaperson

+0

코드 스 니펫을 실행 했습니까 ?? – amyth

0
.li:active { 
      background-color: yellow; 
     } 

사용이 CSS를 코딩 앵커 태그 ... 행복과 데이터 토글 = "알약"을 사용해야합니다 그래서 당신의 링크가 클릭되었을 때 당신의 전체적인 레이아웃에 영향을 미치지 않을 노란 색으로 배경색이 변경됩니다 :)

+0

이 방법도 작동하지 않습니다. 왜'#topnav .li : not (.active)> a : not (: hover)인지 알고 싶습니다. { background-color : transparent! important; }' – jajaperson

관련 문제