html - 响应式 CSS 帮助 - 图像/Div 比率

标签 html css twitter-bootstrap-3 responsive-design

我需要 CSS/响应式代码方面的帮助。随着我的窗口大小减小,我需要所有元素以相同的比例减小。对此有疑问。箭头和公鸡不会随着视口(viewport)减小而减小。

公鸡脚的影子应该稍微被箭遮住。箭头主体(不是箭头)的顶部应与灰色和白色部分之间的分界线保持一致。

我需要 CSS/响应式代码方面的帮助。随着我的窗口大小减小,我需要所有元素以相同的比例减小。对此有疑问。箭头和公鸡不会随着视口(viewport)的减小而减小。

公鸡脚的影子应该稍微被箭遮住。箭头主体(不是箭头)的顶部应与灰色和白色部分之间的分界线保持一致。

http://www.bootply.com/fiF4GI3g0n

body {
  margin: 0px;
}
.special_box {
  background-image: url("http://beta.madrooster.com/images/special_bg.png");
  background-repeat: no-repeat;
  background-size: 100% auto;
  height: 434px;
  max-width: 100%;
  position: relative;
  z-index: 1
}
.special_content {
  position: absolute;
  margin: auto;
  height: 85%;
  width: 70%;
  top: 0;
}
.rodney {
  position: absolute;
  margin: auto;
  height: auto;
  width: 100%;
  text-align: right;
  top: 4%;
  right: 16%;
  z-index: 5;
}
.rodney img {
  max-width: 315px;
  height: auto;
}
.special_arrow {
  position: absolute;
  margin: auto;
  bottom: 0;
  left: 0;
  z-index: 10;
}
.special_arrow img {
  max-width: 916px;
  height: auto;
  display: block;
}
<div class="special_box">
  <div class="special_content"></div>
  <div class="rodney">
    <img src="http://beta.madrooster.com/images/special_rodney.png" alt="rodney" />
  </div>
  <div class="special_arrow">
    <img src="http://beta.madrooster.com/images/special_arrow.png" alt="arrow" />
  </div>
</div>

最佳答案

响应式设计

试试这个。使用此代码,箭头会根据屏幕尺寸减小尺寸。你可以随意编辑它,

Use @media screen property to display content with respect to screen size

<html>
<head>
<style>
body {
     margin: 0px;
}
.special_box {
     background-image: url("http://beta.madrooster.com/images/special_bg.png");
     background-repeat: no-repeat;
     background-size: 100% auto;
     height: 434px;
     max-width: 100%;
     position: relative;
     z-index: 1
}
.special_content {
     position: absolute;
     margin: auto;
     height: 85%;
     width: 70%;
     top: 0;
}
.rodney {
     position: absolute;
     margin: auto;
     height: auto;
     width: 100%;
     text-align: right;
     top: 4%;
     right: 16%;
     z-index: 5;
}
.rodney img {
     max-width: 315px;
     height: auto;
}
.special_arrow {
     position: absolute;
     margin: auto;
     bottom: 0;
     left: 0;
     z-index: 10;
}
.special_arrow img {
     width:60%;
     height: auto;
     display: block;
}
@media screen and (max-width:1800px){
     .special_arrow img {
     width:98%;
     height: auto;
     display: block;
     }
}
</style>
</head>

<body>
<div class="special_box">
  <div class="special_content"> </div>
  <div class="rodney"> <img    src="http://beta.madrooster.com/images/special_rodney.png" alt="rodney"/> </div>
  <div class="special_arrow"> <img src="http://beta.madrooster.com/images/special_arrow.png" alt="arrow"/> </div>
</div>
</body>
</html>

关于html - 响应式 CSS 帮助 - 图像/Div 比率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33005508/

相关文章:

javascript - 提交时反转复选框 : Set HTML form value only if checkbox is unchecked

javascript - 想要使用 javascript 获取标签的值

javascript - 动态调整 Chrome 扩展弹出窗口高度

css - 如何使 div 内容响应?

html - border-radius.htc 在特定页面上的 IE8 中断(在更简单的演示页面中工作)

twitter-bootstrap-3 - 谷歌地图 iframe 无法正确显示 Bootstrap 折叠面板折叠

javascript - 如何只显示一个具有相同类别的div,然后显示其他div

javascript - 避免多次加载相同的 JavaScript

html - CSS Opacity继承问题

css - Bootstrap 3 : Can the Glyphicons be stacked like Font Awesome's icons?