【问题标题】:Overlay 2 divs with one div (ASP.NET Core)用一个 div 覆盖 2 个 div (ASP.NET Core)
【发布时间】:2017-11-16 07:44:00
【问题描述】:

我的视图中有 2 个部分。

查看代码如下:

<section id="about" class="container content-section text-center">
    <div class="row">
        <div class="col-lg-8 col-lg-offset-2">
            <h2>About Grayscale</h2>
            <p>
               
            </p>
            <p>
              
            </p>
            <p>Н</p>
        </div>
       
</section>
<!-- Download Section -->
<section id="download" class="content-section text-center">
    <div class="download-section"> 
        <div class="container">
            <div>
                <h2 style="text-align: center;">Программа обучения VR</h2>
               <div style="width:30%;height:530px;float:left;border-style:solid;border-width:15px;border-color:#42DCA3">
                   <p style="padding-top:10px;font-size:30px;"><b>VR</b></p>
                   <p style="color:#FFD700;font-size:35px;"><b><strike>3600  грн </strike></b></p>
                   <p style="color:black;font-size:28px;"><b>2600  грн до 24.06.17 </b></p>
                   <div style="border-bottom: 1px solid #42DCA3;border-top: 1px solid #42DCA3;padding: 20px 0;margin-bottom: 20px;font-size:20px;">
                         6 недель, 12 занятий,36 часов<br>
                         + практика с HTC Vive<br>
                         + создание 3D объектов<br>
                         + создание ролика с камерой 360°
                   </div>
                   <div style="font-size:20px;">Старт 01.07.17</div>
                   <div style="margin: 0 auto;padding-top:20px;">
                <button class="btn btn-default btn-lg" data-toggle="modal" data-target="#myModal">Оставить заявку</button>
                </div>
               </div>
              
            </div>
           
        </div>
    </div>

Here is all code with css

我需要在设计中创建覆盖这 2 个 div 的块

我该怎么做?

谢谢你的帮助。

【问题讨论】:

    标签: javascript jquery html css asp.net


    【解决方案1】:

    为了将价格块正确定位在左侧,它应该是第一个元素(参见下面的 sn-p)。 不确定您所说的叠加是什么意思,因为这可以通过使用图像和深色作为 DIV 的背景来实现,因此不需要实际的叠加。

    如果您需要覆盖 div,那么您可以使用绝对位置或使用弹性框。

    <section id="about" class="container content-section text-center">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2">
                <h2>About Grayscale</h2>
                <p>
                   
                </p>
                <p>
                  
                </p>
                <p>Н</p>
            </div>
           
    </section>
    <!-- Download Section -->
    <section id="download" class="content-section text-center">
        <div class="download-section"> 
            <div class="container">
                <div>
                    
                   <div style="width:30%;height:530px;float:left;border-style:solid;border-width:15px;border-color:#42DCA3; margin-right: 20px">
                       <p style="padding-top:10px;font-size:30px;"><b>VR</b></p>
                       <p style="color:#FFD700;font-size:35px;"><b><strike>3600  грн </strike></b></p>
                       <p style="color:black;font-size:28px;"><b>2600  грн до 24.06.17 </b></p>
                       <div style="border-bottom: 1px solid #42DCA3;border-top: 1px solid #42DCA3;padding: 20px 0;margin-bottom: 20px;font-size:20px;">
                             6 недель, 12 занятий,36 часов<br>
                             + практика с HTC Vive<br>
                             + создание 3D объектов<br>
                             + создание ролика с камерой 360°
                       </div>
                       <div style="font-size:20px;">Старт 01.07.17</div>
                       <div style="margin: 0 auto;padding-top:20px;">
                    <button class="btn btn-default btn-lg" data-toggle="modal" data-target="#myModal">Оставить заявку</button>
                    </div>
                   </div>
                  <h2 style="text-align: center; padding-top: 100px;">Программа обучения VR</h2>
    <div style="padding: 10px;">01</br>02</br>03</br>04</br>05</br></div>
                </div>
               
            </div>
        </div>

    加法

    这里是简单的代码 sn-p,如果这是您正在寻找的绝对位置。

    .top-div {
      width: 400px;
      height: 200px;
      background: url('https://photos.smugmug.com/Stock-images/Westward-Expansion-Photos/gettysburg-battlefield-photos/i-S8rSqgg/1/70e2c6c8/S/Gettysburg%20Battlefield%20Photos-S.jpg');
    }
    .bottom-div {
      width: 400px;
      height: 400px;
      background: Orange;
      box-sizing: border-box;
      padding: 10px 10px 10px 200px;
    }
    .overlay-holder {
      position: relative;
    }
    .overlay {
      position: absolute;
      top: 100px;
      left: 10px;
      width: 180px;
      background: LightBlue;
      box-sizing: border-box;
      padding: 10px;
    }
    <div class="overlay-holder">
      <div class="overlay">
        This text is in the overlay<br/>
        This text is in the overlay<br/>
        This text is in the overlay<br/>
        This text is in the overlay<br/>
        This text is in the overlay<br/>
        This text is in the overlay<br/>
        This text is in the overlay<br/>
        This text is in the overlay<br/>
        This text is in the overlay<br/>
      </div>
    </div>
    <div class="top-div"></div>
    <div class="bottom-div">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </div>

    【讨论】:

    • 正如您从设计中看到的那样,我有带图像的 div 和带纯色的 div 以及这两个 div 下的一个块。
    • 您的图片不必是 div,它可以是您下载部分的背景图片,例如背景: url('path/to/your/image') #yoursolidcolor no-repeat top center;
    猜你喜欢
    • 1970-01-01
    • 2021-07-12
    • 2014-01-26
    • 1970-01-01
    • 2013-01-27
    • 2011-10-06
    • 1970-01-01
    • 2011-02-25
    相关资源
    最近更新 更多