簡體   English   中英

如何使2個div的中間尺寸可調整大小以更改大小? (上午使用引導程序4)

[英]How to make the middle of 2 divs resizable to change sizing? (am using bootstrap 4)

我有以下布局:

我想這樣做,以便用戶可以將光標置於content1和content2的中間,並可以左右拖動以調整大小(使content1變大/ content2變小。有沒有辦法用我當前的碼? 在此處輸入圖片說明

的CSS

body{
  height: 100%;
  width: 100%;
}
.main-wrapper{
  background-color: #f5f5f5;
  height: 100%;
  left: 0;
  padding-bottom: 50px;
  padding-top: 50px;
  position: fixed;
  top: 0;
  width: 100%;
}
@media (max-width: 991px){
  .main-wrapper{
    overflow-x: hidden;
    overflow-y: auto;
  }
}
.header-wrapper{
  background-color: #009688;
  color: white;
  height: 50px;
  width: 100%;
}
.footer-wrapper{
  background-color: #121212;
  color: white;
  height: 50px;
  width: 100%;
}
.body-wrapper{
  background-color: #f0f0f0;
  width: 100%;
}
.content-1{
  background-color: #2DC050;
  color: white;
  padding: 30px;
  width: 100%;
}
.content-2{
  background-color: #1FA325;
  color: white;
  padding: 30px;
  width: 100%;
}
@media (min-width: 992px){
  .content-1,
  .content-2{
    overflow-x: hidden;
    overflow-y: auto;
  }
}

的HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
<div class="main-wrapper d-flex flex-row">
  <div class="header-wrapper fixed-top d-flex flex-row align-items-center justify-content-center">
    I'm fixed header. I will be alwase visible on top. I'm fixed height.
  </div>
  <div class="body-wrapper d-flex flex-row flex-wrap">
    <div class="col-12 col-lg-6 d-flex flex-row pl-0 pr-0">
      <div class="content-1 d-flex flex-column text-center">
        <h1>I'm content One. My position is left. I'm alwase fit with any browser window except header and footer height. Also I'm scrollable if content isn't fit.</h1>
        <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
      </div>
    </div>
    <div class="col-12 col-lg-6 d-flex flex-row pl-0 pr-0">
      <div class="content-2 d-flex flex-column">
        <h1>I'm content Two. My position is right. I'm alwase fit with any browser window except header and footer height. Also I'm scrollable if content isn't fit.</h1>
        <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
      </div>
    </div>
  </div>
  <div class="footer-wrapper fixed-bottom d-flex flex-row align-items-center justify-content-center">
    I'm fixed footer. I will be alwase visible on bottom. I'm fixed height.
  </div>
</div>
 Run code snippetExpand snippet
Header and Footer always fixed.
Content 1 and Content 2 will be scroll-able if browser min-width is 992px.
Entire page will be scroll-able if browser max-width is 991px.
Edit for Ronaldo comments. Answer is yes it's possible. Check the bottom snippet.

body{
  height: 100%;
  width: 100%;
}
.main-wrapper{
  background-color: #f5f5f5;
  height: 100%;
  left: 0;
  padding-bottom: 50px;
  padding-top: 50px;
  position: fixed;
  top: 0;
  width: 100%;
}
.header-wrapper{
  background-color: #009688;
  color: white;
  height: 50px;
  width: 100%;
}
.footer-wrapper{
  background-color: #121212;
  color: white;
  height: 50px;
  width: 100%;
}
.body-wrapper{
  background-color: #f0f0f0;
  width: 100%;
}
@media (max-width: 991px){
  .body-wrapper{
    overflow-x: hidden;
    overflow-y: auto;
  }
}
.content-1{
  background-color: #2DC050;
  color: white;
  padding: 30px;
  width: 100%;
}
.content-2{
  background-color: #1FA325;
  color: white;
  min-height: 700px;
  padding: 30px;
  width: 100%;
}
@media (min-width: 992px){
  .content-1{
    overflow-x: hidden;
    overflow-y: auto;
  }
}
.content-2-1{
  background-color: #0D420F;
  padding: 20px;
  width: 100%;
}


<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
<div class="main-wrapper d-flex flex-row">
  <div class="header-wrapper fixed-top d-flex flex-row align-items-center justify-content-center">
    I'm fixed header. I will be alwase visible on top. I'm fixed height.
  </div>
  <div class="body-wrapper d-flex flex-row flex-wrap">
    <div class="col-12 col-lg-6 d-flex flex-row pl-0 pr-0">
      <div class="content-1 d-flex flex-column text-center">
        <h1>I'm content One. My position is left. I'm alwase fit with any browser window except header and footer height. Also I'm scrollable if content isn't fit.</h1>
        <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
      </div>
    </div>
    <div class="col-12 col-lg-6 d-flex flex-row pl-0 pr-0">
      <div class="content-2 d-flex flex-column">
        <h1>I'm content Two. My position is right. I'm alwase fit with any browser window except header and footer height. Also I'm scrollable if content isn't fit.</h1>
        <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
      </div>
    </div>
  </div>
  <div class="footer-wrapper fixed-bottom d-flex flex-row align-items-center justify-content-center">
    I'm fixed footer. I will be alwase visible on bottom. I'm fixed height.
  </div>
</div>

好吧,我認為您不能僅使用純HTML和CSS屬性來做到這一點。 使用Jquery resizable()允許您通過draggin調整div的大小。

<script>
   $( function() {
      $( "#divID" ).resizable();
   } );
</script>`

來源: https : //jqueryui.com/resizable/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM