我在做一个网站在css和麻烦了一整天,使图像的一部分隐藏时,它溢出和另一部分不,也移动图像上下. 以下是HTML代码:

    <section class="next-gen">
    <div class="text-content">
        <h1>Next generation <br>
            digital banking</h1>
        <p>Take your financial life online. Your Easybank account <br> will be a one-stop-shop for spending,
            saving,<br>
            budgeting, investing, and much more.</p>
        <button class="request-button">Request Invite</button>
    </div>
    <div class="image-content">
        <img src="images/bg-intro-desktop.svg" alt="" class="image-1">
        <img src="images/image-mockups.png" alt="" class="image-2">

    </div>
</section>[![enter image description here][1]][1]

这是此div的css:

 .next-gen{
    
    padding-left: 10%;
    background-color: hsl(0, 0%, 98%);
    font-family: "Public Sans", sans-serif;
    display: flex;
    height: 450px;
}
.text-content p{
    padding-top: 10px;
    padding-bottom: 10px;
    color: hsl(233, 8%, 62%);
}
.image-content {
    position: absolute;   
    left: 1000px;
    overflow: hidden;
   
}

.image-2 {
  position: absolute;
  right: 250px;
  bottom: 210px;
  z-index: 5;
 }

This is what is currently displayed on the site: enter image description here

And this is expected outcome:enter image description here

当前问题:

enter image description here

我没有发现类似的问题.

推荐答案

首先,如果我没记错的话,你有两张图片Image-1作为背景,Image-2是手机的图片.

.image-content {
    position: absolute;   
    right: 0;
    height: 100%;
    background-image: url("images/bg-intro-desktop.svg");
}

.image-2 {
  position: absolute;
  right: 0;
  bottom: /*align it so that it comes in the center of the main div*/
  z-index: 5; /*Less Than your z-index of nav if have if not add a higher z-index than this to your nav*/
 }

现在,您拥有文本的div和按钮为它提供了一个

职位:相对;

和使用最小宽度而不是宽度IF HAVE

它很可能会解决你的问题,如果不能,请提供一些更多的信息,包括你有文本和按钮的div.

Html相关问答推荐

D3.js—分组条形图—更新输入数据时出错

删除第一个列表项上的左边框

如何让QML`Text`元素内的链接在悬停时显示鼠标指针?

VBA从公共Google Drive地址下载文档-.Click事件(?)

如何收集<;p&>元素下的<;p>;子元素

创建带有弯曲边框的水平时间线

图像不在HTML文件中显示

IFRAME中的Chrome图像未调整大小

渐变进度条位置

当底部进入视图时从底部粘性定位

添加带有悬停动画的喜欢图标

:after 伪元素没有出现,即使它有 content 属性

如何使用 Flutter 构建 Chrome 扩展?

复制两个

会产生一个空行;复制

元素不会

使用修饰键微调 HTML 输入范围中的值

水平对齐两列中的两个按钮 同一级别

另一个 flex 元素之间的 CSS 空间

svg 内容超过元素

Bootstrap Grid System col 无法正常工作

更改包含图标高度的 div