css - 关闭按钮的CSS位置

标签 css asp.net-mvc

我有一个底部有关闭按钮的模式。它似乎在上下移动,具体取决于顶部评论部分的长度。无论评论部分有多长,我都试图将它的位置固定在底部。所以我使用了relative,但如果你们有更好的想法来解决这个问题,我将不胜感激。谢谢。

查看:

<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>

关于css - 关闭按钮的CSS位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39497692/

相关文章:

c# - Azure AD graph api 在本地工作但在部署时失败

javascript - 卡片翻转悬停并单击

css错误显示inline-table

c# - 在我自己的页面中显示 ELMAH 错误详细信息?

asp.net-mvc - 为什么 ASP.NET MVC 不使用通用操作方法?

c# - 如何在 ASP.NET MVC 中获取模型的 HtmlHelper<TModel> 实例?

javascript - 为什么添加bootstrap后代码不工作

CSS - 当从左向右而不是从右向左移动时,根据悬停元素闪烁而变化的自定义光标

css - 移动设备上的 Bootstrap 下拉菜单截断

asp.net-mvc - 我应该如何处理 ASP.NET MVC 中的删除情况