RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 763057
Accepted
Randall
Randall
Asked:2020-12-25 20:27:27 +0000 UTC2020-12-25 20:27:27 +0000 UTC 2020-12-25 20:27:27 +0000 UTC

溢出:隐藏为什么图像在悬停时超出其块

  • 772

.main {
	background-color: transparent;
	width: auto;
	position: relative;
	height: 100%;

}

.center_content {
	padding: 0;
	background-color: #ebeced;
	margin: 0 auto;
}

.container_itemlist {
	min-height: 200px;
	position: relative;
}
#item-list {
	max-width: 975px;
	/*margin-left: 0px;
	margin: 0 auto;*/
}
.hotellist {
	min-height: 578px;
}
.item {
	position: relative;
	display: -webkit-flex;
	display: flex;
	width: 100%;
	margin-bottom: 8px;
	box-shadow: 0 1px 4px rgba(41,51,57,.5);
	color: #37454d;
	background: #fff;
}
.item_wrapper {
	width: 100%;
	position: relative;
}
ol {
	list-style-type: none;
	padding: 0;
}
.image-wrapper:before {
	content: "";
	display: block;
	padding-top: 100%;
}
.item_image {
	position: absolute;
    top: 0;
    width: 100%;
    height: auto;
    left: 0;
    -webkit-transition: -webkit-transform .3s;
    transition: -webkit-transform .3s;
    transition: transform .3s;
    transition: transform .3s,-webkit-transform .3s;
}
.image-area {
	padding: 8px 6px 8px 8px;
	width: 22.25%;
	float: left;
}
.image-wrapper {
	position: relative;
	line-height: 0;
	overflow: hidden;
}

.image-wrapper:hover{
	-webkit-transform: scale(1.05);
    transform: scale(1.05);
}
.image_gallery {
	top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    margin: 0;
    -webkit-transition: opacity .3s;
    transition: opacity .3s;
    opacity: 0;
    display: block;
    background: 0;
    position: absolute;
    cursor: pointer;
    padding: 0;
    border:0;
} 
.image_gallery:hover {
	opacity: 1;
}
.text_wrapper {
	 left: 0;
    right: 0;
    bottom: 0;
    position: absolute;
    height: 71.5%;
    background-image: -webkit-linear-gradient(top,transparent,rgba(0,0,0,.25) 60%,rgba(0,0,0,.75));
    background-image: linear-gradient(180deg,transparent,rgba(0,0,0,.25) 60%,rgba(0,0,0,.75));
}
.image_text {
	 color: #fff;
    font-weight: 700;
    line-height: normal;
    padding-top: 16px;
    font-size: 14px;
    bottom: 8px;
    left: 0;
    right: 0;
    position: absolute;
}
<div class="main">
  <div class="center_content">
    <div class="container_itemlist">
      <section id="item-list">
        <ol class="hotellist">
          <li class="item-order">
            <article class="item">
              <div class="item_wrapper">
                <div class="image-area">
                  <div class="image-wrapper">
                    <img src="http://imgec.trivago.com/itemimages/44/39/443961_v1_isq.jpeg" class="item_image">
                    <button type="button" class="image_gallery">
                      <span class="text_wrapper">
                        <span class="image_text">View images</span>
                      </span>
                    </button>
                  </div>
                </div>
              </div>
            </article>
          </li>
        </ol>
      </section>
    </div>
  </div>
</div>

为什么悬停时图片超出了块我需要它在块内增加,如图所示,而不是超出块。在父元素Overflow hidden中,我指出正确,我不知道我做错了什么。请帮忙

html
  • 2 2 个回答
  • 10 Views

2 个回答

  • Voted
  1. Best Answer
    Andrey Fedorov
    2020-12-25T20:45:57Z2020-12-25T20:45:57Z

    因为您需要裸露容器内部的东西item_image,而不是容器本身image_wrapper。

    PS:由于您的按钮应该在图片的顶部,在工作版本中,悬停应该在按钮上,以便放大图片。在 html 中交换他们的按钮和图像,然后您可以在 css - 中设置选择器button:hover + img {}。

    .main {
    	background-color: transparent;
    	width: auto;
    	position: relative;
    	height: 100%;
    
    }
    
    .center_content {
    	padding: 0;
    	background-color: #ebeced;
    	margin: 0 auto;
    }
    
    .container_itemlist {
    	min-height: 200px;
    	position: relative;
    }
    #item-list {
    	max-width: 975px;
    	/*margin-left: 0px;
    	margin: 0 auto;*/
    }
    .hotellist {
    	min-height: 578px;
    }
    .item {
    	position: relative;
    	display: -webkit-flex;
    	display: flex;
    	width: 100%;
    	margin-bottom: 8px;
    	box-shadow: 0 1px 4px rgba(41,51,57,.5);
    	color: #37454d;
    	background: #fff;
    }
    .item_wrapper {
    	width: 100%;
    	position: relative;
    }
    ol {
    	list-style-type: none;
    	padding: 0;
    }
    .image-wrapper:before {
    	content: "";
    	display: block;
    	padding-top: 100%;
    }
    .item_image {
    	position: absolute;
        top: 0;
        width: 100%;
        height: auto;
        left: 0;
        -webkit-transition: -webkit-transform .3s;
        transition: -webkit-transform .3s;
        transition: transform .3s;
        transition: transform .3s,-webkit-transform .3s;
    }
    .image-area {
    	padding: 8px 6px 8px 8px;
    	width: 22.25%;
    	float: left;
    }
    .image-wrapper {
    	position: relative;
    	line-height: 0;
    	overflow: hidden;
    }
    
    .image_gallery:hover + .item_image {
    	-webkit-transform: scale(1.05);
        transform: scale(1.05);
    }
    .image_gallery {
    	top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        margin: 0;
        -webkit-transition: opacity .3s;
        transition: opacity .3s;
        opacity: 0;
        display: block;
        background: 0;
        position: absolute;
        cursor: pointer;
        padding: 0;
        border:0;
        z-index: 100;
    } 
    .image_gallery:hover {
    	opacity: 1;
    }
    .text_wrapper {
    	 left: 0;
        right: 0;
        bottom: 0;
        position: absolute;
        height: 71.5%;
        background-image: -webkit-linear-gradient(top,transparent,rgba(0,0,0,.25) 60%,rgba(0,0,0,.75));
        background-image: linear-gradient(180deg,transparent,rgba(0,0,0,.25) 60%,rgba(0,0,0,.75));
    }
    .image_text {
    	 color: #fff;
        font-weight: 700;
        line-height: normal;
        padding-top: 16px;
        font-size: 14px;
        bottom: 8px;
        left: 0;
        right: 0;
        position: absolute;
    }
    <div class="main">
      <div class="center_content">
        <div class="container_itemlist">
          <section id="item-list">
            <ol class="hotellist">
              <li class="item-order">
                <article class="item">
                  <div class="item_wrapper">
                    <div class="image-area">
                      <div class="image-wrapper">
                        <button type="button" class="image_gallery">
                          <span class="text_wrapper">
                            <span class="image_text">View images</span>
                          </span>
                        </button>
                        <img src="http://imgec.trivago.com/itemimages/44/39/443961_v1_isq.jpeg" class="item_image">
                      </div>
                    </div>
                  </div>
                </article>
              </li>
            </ol>
          </section>
        </div>
      </div>
    </div>

    • 1
  2. koroche_vot
    2020-12-25T20:45:49Z2020-12-25T20:45:49Z

    将您的图像设置transition: all 1s ease-out;为 ,并在悬停时添加transform: scale(1.1);

    • 0

相关问题

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    Python 3.6 - 安装 MySQL (Windows)

    • 1 个回答
  • Marko Smith

    C++ 编写程序“计算单个岛屿”。填充一个二维数组 12x12 0 和 1

    • 2 个回答
  • Marko Smith

    返回指针的函数

    • 1 个回答
  • Marko Smith

    我使用 django 管理面板添加图像,但它没有显示

    • 1 个回答
  • Marko Smith

    这些条目是什么意思,它们的完整等效项是什么样的

    • 2 个回答
  • Marko Smith

    浏览器仍然缓存文件数据

    • 1 个回答
  • Marko Smith

    在 Excel VBA 中激活工作表的问题

    • 3 个回答
  • Marko Smith

    为什么内置类型中包含复数而小数不包含?

    • 2 个回答
  • Marko Smith

    获得唯一途径

    • 3 个回答
  • Marko Smith

    告诉我一个像幻灯片一样创建滚动的库

    • 1 个回答
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Алексей Шиманский 如何以及通过什么方式来查找 Javascript 代码中的错误? 2020-08-03 00:21:37 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    user207618 Codegolf——组合选择算法的实现 2020-10-23 18:46:29 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5