【问题标题】:css image spacing rightcss 图像间距正确
【发布时间】:2016-09-18 08:11:41
【问题描述】:

我正在尝试在右侧创建“宝丽来”图像效果,但不知道如何做两件事。

  1. 我想要一些空白“围绕”我创建的投影/宝丽来图像,并在其周围显示文字。
  2. 我想让它们在另一个之上。即第一张图片,然后是第二张图片(因此看起来一张图片位于另一张图片之上,但只是部分图片)。

有什么办法吗?

图像应出现在“右侧” - 但边距为 50 像素(空白)。 (即,我想要一堆我输入的文本 - 并且图像出现在页面的“顶部”,但在最右边,彼此堆叠,例如 50px 的空白,因此文本不会“触摸”旋转后的图像。

HTML

<div style="border:10px;border-style:solid">
    <div class="polaroid rotate_right" style="float:right;z-index:100;">
        <img src="sampleimage001" alt="">
        <center>Picture 001</center>
    </div>
    <div class="polaroid rotate_left" style="float:right;">
        <img src="sampleimage002" alt="">
        <center>Picture 002</center>
    </div>
</div>

这是我目前正在使用的 CSS。

div.polaroid {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    padding: 10px 10px 20px 10px;
    border: 1px solid #BFBFBF;
    background-color: white;
    box-shadow: 10px 10px 5px #aaaaaa;
}

div.rotate_right {
    float: left;
    -ms-transform: rotate(7deg); /* IE 9 */
    -webkit-transform: rotate(7deg); /* Safari */
    transform: rotate(7deg);
}

div.rotate_left {
    float: left;
    -ms-transform: rotate(-8deg); /* IE 9 */
    -webkit-transform: rotate(-8deg); /* Safari */
    transform: rotate(-8deg);
}

【问题讨论】:

  • 你应该玩box-shadow属性
  • &lt;center&gt; ?!?!?!?

标签: css flow


【解决方案1】:

我清理了您的一些内联样式和 CSS。宝丽来容器现在使用绝对定位来对齐,让您的照片以您描述的方式堆叠。您能解释一下文本周围需要 50 像素的空白是什么意思吗?

这是一个 Codepen 示例:http://codepen.io/stevenng/pen/GZbeXe

HTML:

  <div class="pic-container">
    <div class="polaroid rotate_right">
        <img src="http://lorempixel.com/200/200" alt="">
        <center>Picture 001, bunch of text</center>
    </div>
    <div class="polaroid rotate_left">
        <img src="http://lorempixel.com/200/200" alt="">
        <center>Picture 002</center>
    </div> </div>

CSS:

div.polaroid {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    padding: 10px 10px 20px 10px;
    border: 1px solid #BFBFBF;
    background-color: white;
    box-shadow: 10px 10px 5px #aaaaaa;
}

div.rotate_right {
    float: left;
    -ms-transform: rotate(7deg); /* IE 9 */
    -webkit-transform: rotate(7deg); /* Safari */
    transform: rotate(7deg);
}

div.rotate_left {
    float: left;
    -ms-transform: rotate(-8deg); /* IE 9 */
    -webkit-transform: rotate(-8deg); /* Safari */
    transform: rotate(-8deg);
}

.pic-container {
  position: absolute;
  right: 0;
  max-width: 200px;
}

【讨论】:

  • 嗨 - 谢谢 - 我的意思是除了图像之外添加“常规”文本。即,就像说“在右边,你会看到这些图像......文本更多文本更多文本更多文本文本更多文本更多文本更多文本更多文本更多文本更多文本更多文本更多文本更多文本更多文本更多文本”更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本 更多文本并且图像应该与文本有 50px 的空白边距
  • 您好,我更新了我的 CSS 并应用了 max-width,因此当您输入更多文本时,它仍然看起来像一个拉长的宝丽来。这是你想要的吗?
  • 不,不是我要找的。不过我想通了。但基本上,我一直在寻找这样的东西:
  • [大容器] text text text [图像容器] [/big container]
猜你喜欢
  • 2011-11-10
  • 2017-11-25
  • 2023-01-14
  • 1970-01-01
  • 2019-03-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-27
相关资源
最近更新 更多