2015-07-13 52 views
0

我正在學習Javascript/jQuery,並試圖使其在點擊提交按鈕後,網站展開並顯示與搜索相關的信息(我還沒有但是,我正在使用一個測試div來顯示它會去哪裏,它並沒有完全顯示,但網站不擴大,沒有滾動功能顯示。網站沒有擴大到顯示jQuery隱藏的信息

<!DOCTYPE html> 
<html lang="end"> 
<head> 
    <meta charset="utf-8" /> 
    <title>League of Legends Summoner Stats</title> 
    <link rel="stylesheet" href="main.css" /> 
    <link rel="stylesheet" href="main.css" /> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
</head> 
<body> 
<div class="center"> 
    <select class="region_selector"> 
     <option value="NA">North America</option> 
     <option value="EUW">EU West</option> 
     <option value="EUNE">EU East</option> 
     <option value="KR">Korea</option> 
    </select> 
</div> 
<div id="title"> 
    <h1>LoL Stat Find</h1> 
</div> 
<div id="subtitle"> 
    <h3>Quickly Find Summoner Stats!</h3> 
</div> 
<button type="submit" id="search_button">Search</button> 
<input name="summoner_name" type="text" maxlength="512" id="summoner_name" placeholder="Summoner Name" class="summoner" /> 
<script src="script.js"></script> 
<div id="stats"> 
    <section id="main"> 
     <h1>THIS IS A TEST</h1> 
     some more testing 
     <br>this is another test 
     <br>another 
    </section> 
</div> 
</body> 
</html> 

這是CSS:

body { 
    background-image: url("background.jpg"); 
    width: 100%; 
    background-size: 100%; 
} 
.region_selector { 
    position: fixed; 
    top: 50%; 
    left: 50%; 
    width: 150px; 
    /* bring your own prefixes */ 
    transform: translate(-100%, -50%); 
    display: inline; 
} 
#summoner_name { 
    position: fixed; 
    top: 50%; 
    left: 50%; 
    /* bring your own prefixes */ 
    transform: translate(5%, -50%); 
    display: inline; 
} 
.summoner { 
    font-size: 14px; 
    border-width: 2px; 
    border-radius: 5px; 
} 
#search_button { 
    position: fixed; 
    top: 50%; 
    left: 50%; 
    /* bring your own prefixes */ 
    transform: translate(-50%, 100%); 
    display: inline-block; 
    margin: 0 10px 0 0; 
    padding: 5px 15px; 
    font-size: 15px; 
    color: white; 
    background-color: #1947D1; 
    font-family: Tahoma; 
    line-height: 1.8; 
    appearance: none; 
    box-shadow: none; 
    border-radius: 5px; 
    border-color: #1947D1; 
} 
#title { 
    position: fixed; 
    top: 50%; 
    left: 50%; 
    /* bring your own prefixes */ 
    transform: translate(-50%, -110%); 
    display:inline; 
    color: white; 
    font-size: 48px; 
    -webkit-text-stroke-width: 1px; 
    -webkit-text-stroke-color: black; 
} 
#subtitle { 
    position: fixed; 
    top: 50%; 
    left: 50%; 
    font-size: 20px; 
    /* bring your own prefixes */ 
    transform: translate(-50%, -130%); 
    font-family: tahoma; 
    -webkit-text-stroke-width: 1px; 
    -webkit-text-stroke-color: black; 
    display: inline; 
    color: #009933; 
    font-style: bold; 
} 
#stats { 
    position: fixed; 
    top: 50%; 
    left: 50%; 
    /* bring your own prefixes */ 
    transform: translate(-50%, 200%); 
} 

這是JavaScript:

$(function() { 
    $("#stats").hide(); 
}); 
document.getElementById('search_button').onclick = function() { 
    var search = document.getElementById('summoner_name').value; 
    $(function() { 
     $("#stats").show(); 
    }); 
} 

我是新來的HTML/CSS/JS所以我的代碼可能是各種各樣的搞砸。

回答

0

由於使用jQuery,用它註冊單擊處理....也是這個問題是應用於#stats

$(function() { 
 
    $("#stats").hide(); 
 

 
    $('#search_button').click(function() { 
 
    $("#stats").show(); 
 
    }); 
 
});
body { 
 
    background-image: url("background.jpg"); 
 
    width: 100%; 
 
    background-size: 100%; 
 
} 
 
.region_selector { 
 
    position: fixed; 
 
    top: 50%; 
 
    left: 50%; 
 
    width: 150px; 
 
    /* bring your own prefixes */ 
 
    transform: translate(-100%, -50%); 
 
    display: inline; 
 
} 
 
#summoner_name { 
 
    position: fixed; 
 
    top: 50%; 
 
    left: 50%; 
 
    /* bring your own prefixes */ 
 
    transform: translate(5%, -50%); 
 
    display: inline; 
 
} 
 
.summoner { 
 
    font-size: 14px; 
 
    border-width: 2px; 
 
    border-radius: 5px; 
 
} 
 
#search_button { 
 
    position: fixed; 
 
    top: 50%; 
 
    left: 50%; 
 
    /* bring your own prefixes */ 
 
    transform: translate(-50%, 100%); 
 
    display: inline-block; 
 
    margin: 0 10px 0 0; 
 
    padding: 5px 15px; 
 
    font-size: 15px; 
 
    color: white; 
 
    background-color: #1947D1; 
 
    font-family: Tahoma; 
 
    line-height: 1.8; 
 
    appearance: none; 
 
    box-shadow: none; 
 
    border-radius: 5px; 
 
    border-color: #1947D1; 
 
} 
 
#title { 
 
    position: fixed; 
 
    top: 50%; 
 
    left: 50%; 
 
    /* bring your own prefixes */ 
 
    transform: translate(-50%, -110%); 
 
    display: inline; 
 
    color: white; 
 
    font-size: 48px; 
 
    -webkit-text-stroke-width: 1px; 
 
    -webkit-text-stroke-color: black; 
 
} 
 
#subtitle { 
 
    position: fixed; 
 
    top: 50%; 
 
    left: 50%; 
 
    font-size: 20px; 
 
    /* bring your own prefixes */ 
 
    transform: translate(-50%, -130%); 
 
    font-family: tahoma; 
 
    -webkit-text-stroke-width: 1px; 
 
    -webkit-text-stroke-color: black; 
 
    display: inline; 
 
    color: #009933; 
 
    font-style: bold; 
 
} 
 
#stats { 
 
    position: fixed; 
 
    top: 1px; 
 
    <!--here is the problem --> left: 50%; 
 
    /* bring your own prefixes */ 
 
    transform: translate(-50%, 200%); 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<div class="center"> 
 
    <select class="region_selector"> 
 
    <option value="NA">North America</option> 
 
    <option value="EUW">EU West</option> 
 
    <option value="EUNE">EU East</option> 
 
    <option value="KR">Korea</option> 
 
    </select> 
 
</div> 
 
<div id="title"> 
 
    <h1>LoL Stat Find</h1> 
 
</div> 
 
<div id="subtitle"> 
 
    <h3>Quickly Find Summoner Stats!</h3> 
 
</div> 
 
<button type="submit" id="search_button">Search</button> 
 
<input name="summoner_name" type="text" maxlength="512" id="summoner_name" placeholder="Summoner Name" class="summoner" /> 
 
<div id="stats"> 
 
    <section id="main"> 
 
    <h1>THIS IS A TEST</h1> 
 
    some more testing 
 
    <br/>this is another test 
 
    <br/>another 
 
    </section> 
 
</div>

+0

http://jsfiddle.net/arunpjohny/樣式pq41ps8c / –