gpt4 book ai didi

html - 具有固定页眉和页脚以及可滚动内容的模式对话框

转载 作者:太空狗 更新时间:2023-10-29 15:39:56 25 4
gpt4 key购买 nike

我正在尝试创建一个模态对话框,它具有固定的页眉和页脚,并且模态对话框内的内容(在本例中为用户列表)是可滚动的...

到目前为止,我最好的尝试给了我图像上的结果:

my best

我假设在看到图像后我不必描述问题是什么......我还假设你会知道解决方案必须是什么样子......:)

但为了确保我无论如何都会写它......模态对话框需要有一个固定的标题(标题“编辑板”“板名称”和“板类型”所在的区域)和页脚( “保存”按钮所在的区域)必须是固定的/不可滚动的……唯一必须滚动的是用户列表……

代码:

HTML:

<div id="addBoardModal" class="modal modal-fixed-footer">
<form class="Boards_new" autocomplete="off">
<div class="modal-header">
<h5>{{title}}</h5>
<div class="input-field">
<!--INPUT FORM-->
<div class="BoadType">
<!--RADIAL BUTTON THING-->
<div class="modal-content">
<div class="shareMembers" style="margin-top:18px;">
<div class="row">
<h5 class="left">Share</h5>
<!--LIST OF USERS !!!THIS HAS TO BE SCROLLABLE!!!-->
</div>
</div>
<div class="modal-footer">
<!--JSUT THIS SAVE BUTTON-->
</div>

CSS:

.modal {
@extend .z-depth-4;
display: none;
position: fixed;
left: 0;
right: 0;
background-color: #fafafa;
padding: 0;
max-height: 70%;
width: 55%;
margin: auto;
//overflow-y: auto;
border-radius: 2px;
will-change: top, opacity;

@media #{$medium-and-down} {
width: 80%; }

h1,h2,h3,h4 {
margin-top: 0; }

.modal-header{
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
width: 100%;
height: 15rem;
padding:24px;
}

.modal-header > .input-field{width:100%;}

.modal-content {
padding: 24px;
position: absolute;
width: 100%;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}

.modal-close {cursor: pointer;}

.modal-footer {
border-radius: 0 0 2px 2px;
border-top: 1px solid rgba(0, 0, 0, 0.1);
background-color: #fafafa;
padding: 4px 6px;
height: 56px;
width: 100%;

.btn, .btn-flat {
float: right;
margin: 6px 0;
}
}
}

因此,如果有人可以告诉我我的代码中哪里做错了,或者我是否应该做一些不同的事情,那会很好...

我使用这些示例来编写代码... Example no.1 & Example no.2

注意:我使用的是 Materialise 框架

最佳答案

您可以使用 calc() 函数尝试 max-height,例如:

.modal-content {
height: auto !important;
max-height: calc(100vh - 340px) !important;
}

看看下面的代码片段(使用全屏):

$(document).ready(function(){
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
$('.modal-trigger').leanModal();
});
.modal {
overflow: hidden;
}

.modal-header {
padding: 15px;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h4 {
margin: 0;
}

.modal-content {
height: auto !important;
max-height: calc(100vh - 340px) !important;
}

.content-row {
display: flex;
align-items: center;
padding: 10px;
border-bottom: 1px solid #ddd;
}

.content-row:last-child {
border-bottom: none;
}

.icon {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: #33b5e5;
color: #fff;
}

.name {
padding: 0 10px;
}

.role {
padding: 0 10px;
flex: 1;
text-align: right;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/css/materialize.css" rel="stylesheet"/>

<!-- Modal Trigger -->
<a class="modal-trigger waves-effect waves-light btn" href="#modal1">Modal</a>

<!-- Modal Structure -->
<div id="modal1" class="modal modal-fixed-footer">
<div class="modal-header">
<h4>Modal Header</h4>
</div>
<div class="modal-content">
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
<div class="content-row">
<div class="icon">1</div>
<div class="name">Name</div>
<div class="role">Role</div>
</div>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">Agree</a>
</div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"></script>

希望这对您有所帮助!

关于html - 具有固定页眉和页脚以及可滚动内容的模式对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41302241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com