1. <legend id='Uj9Qe'><style id='Uj9Qe'><dir id='Uj9Qe'><q id='Uj9Qe'></q></dir></style></legend>
        <bdo id='Uj9Qe'></bdo><ul id='Uj9Qe'></ul>
      <tfoot id='Uj9Qe'></tfoot>
    2. <i id='Uj9Qe'><tr id='Uj9Qe'><dt id='Uj9Qe'><q id='Uj9Qe'><span id='Uj9Qe'><b id='Uj9Qe'><form id='Uj9Qe'><ins id='Uj9Qe'></ins><ul id='Uj9Qe'></ul><sub id='Uj9Qe'></sub></form><legend id='Uj9Qe'></legend><bdo id='Uj9Qe'><pre id='Uj9Qe'><center id='Uj9Qe'></center></pre></bdo></b><th id='Uj9Qe'></th></span></q></dt></tr></i><div id='Uj9Qe'><tfoot id='Uj9Qe'></tfoot><dl id='Uj9Qe'><fieldset id='Uj9Qe'></fieldset></dl></div>

        <small id='Uj9Qe'></small><noframes id='Uj9Qe'>

      1. 使布局为“内联块"的图像在底部具有悬停标题

        Make images layed out as #39;inline-block#39; have on-hover titles on the bottom(使布局为“内联块的图像在底部具有悬停标题)
        <i id='gZ3jY'><tr id='gZ3jY'><dt id='gZ3jY'><q id='gZ3jY'><span id='gZ3jY'><b id='gZ3jY'><form id='gZ3jY'><ins id='gZ3jY'></ins><ul id='gZ3jY'></ul><sub id='gZ3jY'></sub></form><legend id='gZ3jY'></legend><bdo id='gZ3jY'><pre id='gZ3jY'><center id='gZ3jY'></center></pre></bdo></b><th id='gZ3jY'></th></span></q></dt></tr></i><div id='gZ3jY'><tfoot id='gZ3jY'></tfoot><dl id='gZ3jY'><fieldset id='gZ3jY'></fieldset></dl></div>

        • <bdo id='gZ3jY'></bdo><ul id='gZ3jY'></ul>

          1. <legend id='gZ3jY'><style id='gZ3jY'><dir id='gZ3jY'><q id='gZ3jY'></q></dir></style></legend>
              <tbody id='gZ3jY'></tbody>
          2. <small id='gZ3jY'></small><noframes id='gZ3jY'>

            <tfoot id='gZ3jY'></tfoot>

                • 本文介绍了使布局为“内联块"的图像在底部具有悬停标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在开发一个图片库,并希望通过以下方式在图片底部显示标题:

                  I'm developing an image gallery and want to display titles on the bottom of an image in the following way:

                  • 图片默认不显示任何文字

                  • Image is shown without any text by default

                  当鼠标悬停在图像上时,一个(可能被截断的)标题出现在深灰色半透明背景的底部

                  When hovering mouse over image, a (possibly truncated) title appears on the bottom on a dark-gray semi-transparent background

                  最好我的 HTML 保持原样;最重要的是,图像保持为显示:内联块",因为这是布局所需要的.

                  Preferably, my HTML stays as is; most importantly the images remain as 'display: inline-block' as that's how they are needed for the layout.

                  (可选)将鼠标悬停在标题上时(如果它被截断),它会完全展开

                  (Optional) When hovering over the title (if it was truncated) it is expanded fully

                  (可选)标题可以包含链接/整个图像是一个链接

                  (Optional) Titles can contain links / whole image is a link

                  请看图解说明:

                  Please see a graphical explanation:

                  这有点类似于 http://www.flickr.com/explore 和许多其他网站也这样做.

                  This is somewhat similar to how http://www.flickr.com/explore and many other sites do it.

                  这是我目前所拥有的(实际上并没有太多,因为它将标题呈现在垂直中间,而不是在底部):

                  Here is what I have so far (not too much, actually, as it renders the title in the vertical middle, not on the bottom):

                  .image-block {
                      display: inline-block;
                      margin: 0 0 0 0;
                  }
                  
                  .container { /* testing only */
                      width: 1555px;
                      overflow: scroll;
                  }
                  
                  
                  
                  .hover-me {
                     position: relative;
                  
                  }
                  
                  .hover-me img{
                      width:100%;
                      height:auto;
                      display: block;
                  }
                  
                  .hover-me:after {
                      content: '';
                      position: absolute;
                      top: 0;
                      left: 0;
                      right: 0;
                      bottom: 0;
                      z-index: 1;
                      background: rgba(128,128,128,.5);
                      transition: all .5s ease;
                      opacity: 0;
                  }
                  
                  .hover-me .caption {
                      display: block;
                      height: 50%;
                      position: absolute;
                      top: 50%;
                      left: 0;
                      right: 0;
                      margin-top: -10px;
                      text-align: center;
                      transition: all .5s ease;
                      opacity: 0;
                      z-index: 2;
                      color: #fff;
                  }
                  
                  .hover-me:hover:after , .hover-me:hover .caption {
                      opacity: 1;
                  }

                  <div class="container">
                      <span  class="image-block hover-me ng-scope" style="padding-right: 5px; padding-bottom: 5px; height: 257px; width: 269px;">
                              <img class="hovertext" width="269" height="257" src="http://i.imgur.com/zOEilgll.jpg">
                             <span class="caption">This is a longish text of what looks like a camel; really quote a long long long long long long long long long long long long text</span>
                      </span><span  class="image-block hover-me ng-scope" style="padding-right: 5px; padding-bottom: 5px; height: 257px; width: 385px;">
                              <img class="hovertext" width="385" height="257" src="http://i.imgur.com/jj1dY0sl.jpg">
                             <span class="caption">Well this is quite a pretty picture too</span>
                      </span><span  class="image-block hover-me ng-scope" style="padding-right: 10px; padding-bottom: 5px; height: 257px; width: 396px;">
                              <img class="hovertext" width="396" height="257" src="http://i.imgur.com/yVlWIc0l.jpg">
                             <span class="caption">Omg what is this a black and white picture</span>
                      </span><span  class="image-block hover-me ng-scope" style="padding-right: 0px; padding-bottom: 5px; height: 257px; width: 456px;">
                              <img class="hovertext" width="456" height="257" src="http://i.imgur.com/roRmFJWl.jpg">
                             <span class="caption">This is just an ordinary truck, I think... maybe; but the discription is really quite long</span>
                      </span><span  class="image-block hover-me ng-scope" style="padding-right: 5px; padding-bottom: 5px; height: 289px; width: 433px;">
                              <img class="hovertext" width="433" height="289" src="http://i.imgur.com/yo2WhKFl.jpg">
                             <span class="caption">A great quote frm a great explorer</span>
                      </span>
                      <span>More images follow...</span>
                  </div>

                  推荐答案

                  嗯,很简单,这里需要 CSS 定位,使用 position: relative; 容器包裹元素...我这是从头开始制作的,看看它是否对您有用,如果您需要任何修改,请联系我..

                  Well, it's pretty easy, you will need CSS Positioning here, wrap the element using position: relative; container... I made this from scratch, see if it's useful to you, if you need any modifications, just ping me..

                  说明:首先我制作 .wrap 元素 position: relative; 只是为了确保嵌套的 absolute 定位 span 相对于容器.

                  Explanation: First am making the .wrap element position: relative; just to make sure the nested absolute positioned span stays relative to the container.

                  在下一个选择器中,即 .wrap span 使用 position: absolute; for span 有一个负边距,这是故意溢出的,让它隐藏起来.

                  In the next selector i.e .wrap span am using position: absolute; for span with a negative margin, which is deliberately overflown, so that it hides.

                  进入下一个选择器,即 .wrap:hover span 将显示 span 元素的第一行.

                  Coming to next selector i.e .wrap:hover span will show the first line of the span element.

                  最后一个选择器 .wrap:hover span:hover 将显示其余的文本.

                  And the last selector which is .wrap:hover span:hover will show the rest of the text.

                  演示

                  Demo 2 [1] 固定底部的空白

                  .wrap {
                      position: relative;
                      display: inline-block;
                      overflow: hidden;
                  }
                  
                  .wrap span {
                      position: absolute;
                      bottom: -70px;
                      background: rgba(0,0,0,.8);
                      color: #fff;
                      left: 0;
                      width: 100%;
                      -moz-transition: all .5s;
                      -webkit-transition: all .5s;
                      transition: all .5s;
                  }
                  
                  .wrap:hover span {
                      bottom: -40px;
                  }
                  
                  .wrap:hover span:hover {
                      bottom: 0;
                  }
                  

                  <小时>

                  .wrap img {
                      display: block;
                  }
                  

                  [1] 将此添加到您的代码中以修复图像底部的 white-space.

                  注意:尺寸是固定的,如果您认为每个缩略图可能会有很大的不同,我会推荐你使用jQuery 并相应地设置 span 元素的 height.

                  Note: The dimensions are fixed, if you think the text for each thumbnail may vary to a great extent, than I will recommend you to use jQuery and set the height of the span elements accordingly.

                  这篇关于使布局为“内联块"的图像在底部具有悬停标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Move link image 5px up on hover(悬停时将链接图像向上移动 5px)
                  How do I inspect CSS pseudo classes with firebug?(如何使用 firebug 检查 CSS 伪类?)
                  Why doesn#39;t CSS hover work on table rows when the cells inside the rows have class names?(当行内的单元格具有类名时,为什么 CSS 悬停在表格行上不起作用?)
                  Hover image - display div over it(悬停图像 - 在其上显示 div)
                  How to apply a CSS class on hover to dynamically generated submit buttons?(如何在悬停时将 CSS 类应用于动态生成的提交按钮?)
                  Differences between CSS3 :hover and :focus?(CSS3 :hover 和 :focus 的区别?)

                  <tfoot id='teY6U'></tfoot>

                    <bdo id='teY6U'></bdo><ul id='teY6U'></ul>
                      <tbody id='teY6U'></tbody>
                    <i id='teY6U'><tr id='teY6U'><dt id='teY6U'><q id='teY6U'><span id='teY6U'><b id='teY6U'><form id='teY6U'><ins id='teY6U'></ins><ul id='teY6U'></ul><sub id='teY6U'></sub></form><legend id='teY6U'></legend><bdo id='teY6U'><pre id='teY6U'><center id='teY6U'></center></pre></bdo></b><th id='teY6U'></th></span></q></dt></tr></i><div id='teY6U'><tfoot id='teY6U'></tfoot><dl id='teY6U'><fieldset id='teY6U'></fieldset></dl></div>

                          1. <small id='teY6U'></small><noframes id='teY6U'>

                          2. <legend id='teY6U'><style id='teY6U'><dir id='teY6U'><q id='teY6U'></q></dir></style></legend>