2016-12-17 57 views
0

我试图做到这一点,当您点击一个链接时,它会滚动到下一部分。它似乎滚动得很好,但它总是关闭时,我点击一个链接。有什么办法可以解决这个问题吗?使用链接滚动文章而不关闭模式

.modalDialog { 
 
    position: fixed; 
 
    width: 100%; 
 
    height: 100%; 
 
    font-family: 'gothic' !important; 
 
    top: 0; 
 
    right: 0; 
 
    bottom: 0; 
 
    left: 0; 
 
    background: rgba(0, 0, 0, 0.8); 
 
    z-index: 99999; 
 
    opacity: 0; 
 
    -webkit-transition: opacity 400ms ease-in; 
 
    -moz-transition: opacity 400ms ease-in; 
 
    transition: opacity 400ms ease-in; 
 
    pointer-events: none; 
 
} 
 

 
.modalDialog:target { 
 
    opacity: 1; 
 
    pointer-events: auto; 
 
} 
 

 
.modalDialog > div { 
 
    width: 90%; 
 
    height: 600px; 
 
    position: relative; 
 
    top: 12px; 
 
    margin: auto; 
 
    padding: 5px 20px 13px 20px; 
 
    border-radius: 10px; 
 
    border: solid #2E51A2 2px; 
 
    background-color: #1d1d1d; 
 
    color: #999; 
 
} 
 

 
.close { 
 
    background: #2E51A2; 
 
    color: #fff; 
 
    line-height: 25px; 
 
    position: absolute; 
 
    right: -12px; 
 
    text-align: center; 
 
    top: -10px; 
 
    width: 24px; 
 
    text-decoration: none; 
 
    font-weight: bold; 
 
    -webkit-border-radius: 12px; 
 
    -moz-border-radius: 12px; 
 
    border-radius: 12px; 
 
    -moz-box-shadow: 1px 1px 3px #000; 
 
    -webkit-box-shadow: 1px 1px 3px #000; 
 
    box-shadow: 1px 1px 3px #000; 
 
} 
 

 
.close:hover { 
 
    color: #000; 
 
} 
 

 
#content { 
 
    width: 60%; 
 
    float: right; 
 
    font-family: 'gothic' !important; 
 
    overflow-y: hidden; 
 
    overflow-x: hidden; 
 
    height: 396px; 
 
    border: 2px solid #2E51A2; 
 
    border-bottom-left-radius: 5px; 
 
    border-bottom-right-radius: 5px; 
 
    border-top-right-radius: 5px; 
 
} 
 

 
#description { 
 
    width: 100%; 
 
    height: 396px; 
 
    overflow-y: hidden; 
 
    overflow-x: hidden; 
 
} 
 

 
#contentGuide { 
 
    width: 100%; 
 
    height: 396px; 
 
    overflow-y: scroll; 
 
    overflow-x: hidden; 
 
} 
 

 
.contentLink { 
 
    display: block; 
 
    width: 200px; 
 
    height: 50px; 
 
    border-left: 2px solid #2E51A2; 
 
    border-right: 2px solid #2E51A2; 
 
    border-top: 2px solid #2E51A2; 
 
    border-top-left-radius: 5px; 
 
    border-top-right-radius: 5px; 
 
    background-color: #1d1d1d; 
 
    color: #999; 
 
    position: relative; 
 
    top: 2px; 
 
    right: 4px; 
 
    font-size: 16pt; 
 
    line-height: 50px; 
 
    text-decoration: none; 
 
    text-align: center; 
 
    float: left; 
 
} 
 

 
.contentLink:active { 
 
    background-color: #2E51A2; 
 
} 
 

 
#linkContain { 
 
    width: 60%; 
 
    height: 54px; 
 
    float: right; 
 
}
<a href="#openModal">Open Modal</a> 
 

 
<div id="openModal" class="modalDialog"> 
 
    <div> <a href="#close" title="Close" class="close">X</a> 
 
    <div id="linkContain"> 
 
     <a href="#description" class="contentLink">About</a><a href="#contentGuide" class="contentLink">Content Guide</a> 
 
    </div> 
 
    <article id="content"> 
 
     <article id="description"> 
 
     Content 1 
 
     </article> 
 

 
     <article id="contentGuide"> 
 
     Content 2 
 
     </article> 
 
    </article> 
 
    </div> 
 
</div>

回答

0

与该工作片段尝试,这是你需要什么,我想

$(document).ready(function(){ 
 
    activaTab('aaa'); 
 
}); 
 

 
function activaTab(tab){ 
 
    $('.nav-tabs a[href="#' + tab + '"]').tab('show'); 
 
};
.modalDialog { 
 
\t position: fixed; 
 
\t width: 100%; 
 
\t height: 100%; 
 
\t font-family: 'gothic' !important; 
 
\t top: 0; 
 
\t right: 0; 
 
\t bottom: 0; 
 
\t left: 0; 
 
\t background: rgba(0, 0, 0, 0.8); 
 
\t z-index: 99999; 
 
\t opacity:0; 
 
\t -webkit-transition: opacity 400ms ease-in; 
 
\t -moz-transition: opacity 400ms ease-in; 
 
\t transition: opacity 400ms ease-in; 
 
\t pointer-events: none; 
 
} 
 

 
.modalDialog:target { 
 
\t opacity:1; 
 
\t pointer-events: auto; 
 
} 
 

 
.modalDialog > div { 
 
\t width: 90%; 
 
\t height: 600px; 
 
\t position: relative; 
 
\t top: 12px; 
 
\t margin: auto; 
 
\t padding: 5px 20px 13px 20px; 
 
\t border-radius: 10px; 
 
\t border: solid #2E51A2 2px; 
 
\t background-color: #1d1d1d; 
 
\t color: #999; 
 
} 
 

 
.close { 
 
\t background: #2E51A2; 
 
\t color: #fff; 
 
\t line-height: 25px; 
 
\t position: absolute; 
 
\t right: -12px; 
 
\t text-align: center; 
 
\t top: -10px; 
 
\t width: 24px; 
 
\t text-decoration: none; 
 
\t font-weight: bold; 
 
\t -webkit-border-radius: 12px; 
 
\t -moz-border-radius: 12px; 
 
\t border-radius: 12px; 
 
\t -moz-box-shadow: 1px 1px 3px #000; 
 
\t -webkit-box-shadow: 1px 1px 3px #000; 
 
\t box-shadow: 1px 1px 3px #000; 
 
} 
 

 
.close:hover { 
 
\t color: #000; 
 
} 
 

 
#tabs { 
 
\t width: 60%; 
 
\t float: right; 
 
\t font-family: 'gothic' !important; 
 
\t overflow-y: hidden; 
 
\t overflow-x: hidden; 
 
\t height: 396px; 
 
\t border: 2px solid #2E51A2; 
 
\t border-bottom-left-radius: 5px; 
 
\t border-bottom-right-radius: 5px; 
 
\t border-top-right-radius: 5px; 
 
} 
 

 
#description { 
 
\t width: 100%; 
 
\t height: 396px; 
 
\t overflow-y: hidden; 
 
\t overflow-x: hidden; 
 
} 
 

 
#contentGuide { 
 
\t width: 100%; 
 
\t height: 396px; 
 
\t overflow-y: scroll; 
 
\t overflow-x: hidden; 
 
} 
 

 
.contentLink { 
 
\t display: block; 
 
\t width: 200px; 
 
\t height: 50px; 
 
\t border-left: 2px solid #2E51A2; 
 
\t border-right: 2px solid #2E51A2; 
 
\t border-top: 2px solid #2E51A2; 
 
\t border-top-left-radius: 5px; 
 
\t border-top-right-radius: 5px; 
 
\t background-color: #1d1d1d; 
 
\t color: #999; 
 
\t position: relative; 
 
\t top: 2px; 
 
\t right: 4px; 
 
\t font-size: 16pt; 
 
\t line-height: 50px; 
 
\t text-decoration: none; 
 
\t text-align: center; 
 
\t float: left; 
 
} 
 

 
.contentLink:active { 
 
\t background-color: #2E51A2; 
 
} 
 

 
#linkContain { 
 
\t width: 60%; 
 
\t height: 54px; 
 
\t float: right; 
 
}
<!doctype html> 
 
<html> 
 
<head> 
 
<meta charset="utf-8"> 
 
<title>Untitled Document</title> 
 
<!-- 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"> 
 

 
</head> 
 

 
<body> 
 

 
<a href="#openModal">Open Modal</a> 
 
\t 
 
<div id="openModal" class="modalDialog"> 
 
\t <div> \t <a href="#close" title="Close" class="close">X</a> 
 
\t \t <div id="linkContain"> 
 
\t \t \t <a href="#description" class="contentLink" data-toggle="tab">About</a> 
 
      <a href="#contentGuide" class="contentLink" data-toggle="tab">Content Guide</a> 
 
\t \t </div> 
 
\t \t <article class="tab-content" id="tabs"> 
 
\t \t \t <article class="tab-pane" id="description"> 
 
\t \t \t \t Content 1 
 
\t \t \t </article> 
 
\t \t \t \t 
 
\t \t \t <article class="tab-pane" id="contentGuide"> 
 
\t \t \t \t Content 2 
 
\t \t \t </article> 
 
\t \t </article> 
 
     </div> 
 
</div> 
 

 

 
<!-- /.outer --> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
 
<!-- 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> 
 

 
</body> 
 
</html>