【问题标题】:Full Screen Image with Text/Button (Responsive)带文本/按钮的全屏图像(响应式)
【发布时间】:2013-04-12 02:19:51
【问题描述】:

我正在为客户开发一个复杂的项目。我设计了一个全屏登录页面,需要在所有大小的 windows/mobile 上兼容(响应式)。目前我无法定位图像以覆盖整个页面。 div (slider-full-width) 需要跨越整个窗口。我提供了一张图片来展示我想要实现的目标。我正在使用骨架框架。 http://www.getskeleton.com/ 在这个全屏登陆页面之后,您必须能够继续向下滚动才能看到页面的其余内容。

我的 HTML:

  <div id="slider-full-width">
<div class="container">
  <h2>Seeking a refreshening management service?</h2>
  <h2>You've come to the right place</h2>
  <div id="button-bg">
  <a href="properties.html" class="presentation-button">Properties</a>
  <a href="#body-span-class" class="presentation-button">See why</a>
</div>


我的 CSS:

    #slider-full-width{
width: 100%;
background-image: url('../img/slide-01.jpg');
position:relative;
text-align: center;}
    #slider-full-width h2 {
color: #efefef;

}

非常感谢您!

【问题讨论】:

    标签: css image skeleton-css-boilerplate


    【解决方案1】:

    我不知道为什么它会在顶部留下那个空白,但我已经为你创建了一个 jsfiddle 来展示我做了什么来删除它:http://jsfiddle.net/sKzCc/

    HTML:

    <div id="slider-full-width"> <div class="container">   <h2>Seeking a
    refreshening management service?</h2>   <h2>You've come to the right
    place</h2>   <div id="button-bg">   <a href="properties.html"
    class="presentation-button">Properties</a>
      <a href="#body-span-class" class="presentation-button">See why</a>   </div>
    

    CSS:

    #slider-full-width{ max-width: 100%; min-height:800px; background: url('http://www.wherelionsroam.co.uk/image/two.jpg') no-repeat center
    center fixed; -webkit-background-size: cover; -moz-background-size:
    cover; -o-background-size: cover; background-size: cover;
    position:relative; text-align: center; } #slider-full-width h2 {
    color: #efefef; margin-top:-20px; font-size: 25.29pt; padding-top:
    285px; text-shadow: 1px 1px 1px #000; }
    

    我为所有主流浏览器添加了background-size:cover 标签,以确保最大程度的跨浏览器兼容性。 我希望这个解决方案对你有用!

    【讨论】:

      【解决方案2】:

      如果您希望背景图像覆盖 div,您可以在选择器中使用它:

      #slider-full-width {
          /* Your code */
          background-size: cover;
      }
      

      【讨论】:

      • 这没有帮助:(我需要 div (#slider-full-widt) 跨越整个窗口,没有间隙等。我检查了源图像它足够大。跨度>
      • 所以 div 没有跨越整个宽度?将宽度更改为最大宽度:100%。
      • 它跨越整个宽度而不是垂直高度。图像占用页面的 1/6(y 轴/垂直)而不是全部。我使用高度:100% 吗?
      • div 只会占用内容所需的空间。你可以使用min-height: insert height needed; 它仍然会响应
      • 谢谢!我使用了一个像素值(因为百分比不起作用)。该主题的最后一个问题是文本位于页面顶部,导致出现大白条。将此文本下降 285 像素的最合乎逻辑的方法是什么?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-23
      • 2012-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多