关闭按钮的css位置

问题描述:

我有一个关闭按钮的底部模式。它看起来好像是在上下移动,取决于评论部分在最上面多久。无论评论部分多长时间,我都试图在底部修正它的位置。所以我用相对,但如果你们有更好的主意来解决这个问题,我将不胜感激。谢谢。关闭按钮的css位置

查看:

<div class="form-horizontal"> 
    <div class="modal-title title"> 
     <p>@ViewBag.name<span> Info</span></p> 
    </div> 
    <div id="info"> 
     <p>@Html.Label("Name: ") @ViewBag.name</p> 
     <p>@Html.Label("Age: ") @ViewBag.age</p> 
     <p>@Html.Label("Comment: ") @ViewBag.comment</p> 
    </div> 
    <div id="close"> 
     <div class="col-md-12"> 
      <input type="button" id="closeButton" value="Close" class="btn btn-default" /> 
     </div> 
    </div> 
</div> 

CSS:

.btn { 
    border: 2px solid transparent; 
    background: white; 
    color: black; 
    font-size: 16px; 
    line-height: 15px; 
    padding: 10px 0; 
    display: block; 
    width: 150px; 
    margin: 0 auto; 
} 
.title { 
    position: relative; 
    top: 20px; 
} 
.title p { 
    text-align: center; 
    font-size: 30px; 
} 
.title span { 
    color: black; 
} 
#info {  
    position: relative;  
    top: 50px; 
    left: 20px; 
} 
#info p { 
    font-size: 15px !important; 
    width: 310px; 
} 
#close { 
    position: relative; 
    top: 70px; 
} 

只给固定高度的模态身体,使身体可以在没有改变按钮位置

enter code h 

<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
    <title>Bootstrap Example</title> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
 
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
</head> 
 
<style> 
 
</style> 
 
<body> 
 

 
<div class="container"> 
 
    <h2>Modal Example</h2> 
 
    <!-- Trigger the modal with a button --> 
 
    <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button> 
 

 
    <!-- Modal --> 
 
    <div class="modal fade" id="myModal" role="dialog"> 
 
    <div class="modal-dialog"> 
 
    
 
     <!-- Modal content--> 
 
     <div class="modal-content"> 
 
     <div class="modal-header"> 
 
      <button type="button" class="close" data-dismiss="modal">&times;</button> 
 
      <h4 class="modal-title">Modal Header</h4> 
 
     </div> 
 
     <div class="modal-body" style="height:200px; overflow-y:scroll;"> 
 
      <p>@Html.Label("Name: ") @ViewBag.name</p> 
 
     <p>@Html.Label("Age: ") @ViewBag.age</p> 
 
     <p>@Html.Label("Comment: ") @ViewBag.comment</p> 
 
     </div> 
 
     <div class="modal-footer"> 
 
     <input type="button" id="closeButton" value="Close" class="btn btn-default" /> 
 
     </div> 
 
     </div> 
 
     
 
    </div> 
 
    </div> 
 
    
 
</div> 
 

 
</body> 
 
</html>

ERE

只需添加位置:固定的,如果那是你想要的它沉入水底。

#close { 
    position: fixed; 
    bottom: 0px; 
    left: 50%; 
} 
+0

耶滚动,但然后取决于屏幕尺寸,(例如:如果我按F11将其全屏显示)它开箱即用。无论屏幕分辨率如何,我都可以将该按钮粘贴到模式的底部? – pavilion

+0

我从小提琴中按f11,我仍然看到底部 – Keith