- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我下面的代码中,我有 3 张图片,其中一些图片下方有标题。我不希望文本的宽度超过图像的宽度。注意:图像的宽度可能会有所不同。它不是一个固定的宽度。如果文本超过图像的宽度,则文本需要换行。我在下面的代码中遇到的另一个问题是第二个和第三个图像在图像底部显示了一些填充。此图像周围的边框不应有填充。
http://jsfiddle.net/AndroidDev/Asu7V/15/
<div style="width:300px; overflow-x: auto;white-space: nowrap;">
<div style="vertical-align:top">
<div class="x">
<img src="http://25.media.tumblr.com/avatar_dae559818d30_128.png" />
<div style="white-space:wrap">Grumpy Cat is a famous cat</div>
</div>
<div class="x">
<img src="http://scottsdalepethotel.com/wp-content/uploads/et_temp/cat-648150_128x128.jpg" />
<img src="http://playgo.ro/wp-content/themes/play3.0/play.png" style="position:absolute; left:0; top:0" />
</div>
<div class="x">
<img src="http://blog.sureflap.com/wp-content/uploads/2011/11/Maru.jpg" />
</div>
</div>
</div>
最佳答案
因为你没有为你的 div
元素分配任何 width
所以分配它,而不是使用 white-space: normal;
<div style="white-space: normal; width: 130px;">Grumpy Cat is a famous cat</div>
再次提醒您避免使用内联样式..
此外,当您修复仅包含图像的包装器 div
时,最好使用 max-width
和 max-height
您的 img
,这样它将确保它不会溢出
。
此外,最后但并非最不重要的一点是,考虑使用 p
元素代替 div
,这将为您的文本赋予一些语义意义。
您使用的是 white-space: wrap;
,其中 wrap
不是 white-space
属性的有效值,因此您需要正常
正如您评论的那样,您想要摆脱两边的空白,因此,通过为包装元素分配一些固定的 width
来修复包装元素,以及下面的空白图像问题,可以通过在包装元素上使用 font-size: 0;
来解决,而不是将一些 font-size
分配给文本,或者更好的方法来go 是为你的 img
元素使用 display: block;
。
关于html - 想要文本包裹在 div 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20676153/
我想了解如何正确地从 Parcel 中读取空值。让我们看看我的用例: public class MyModel implements Parcelable { private Long id;
好吧,我知道我必须使用 JDBC 等,但我不确定如何将 jar 实现到我的代码中,我有一个基本代码来打开文件等,但我如何才能真正将 sqlite jar 与我的 java 一起合并类文件可以在任何地方
我想知道是否可以打包(或序列化)ClassLoader 以通过 Message 将其发送到 Android 中的另一个进程。 ClassLoader没有实现 Parcelable/Serializab
在上传到我的域时尝试让我的 SVG 出现在浏览器中时,我 - 类似于我拥有 的其他项目包裹安装 - 创建了一个 静态文件夹 我会将 SVG 文件放入的位置。它现在出现在浏览器中,但是,正在播放的“绘图
我有这样的东西: 我希望以最简单的方式实现这样的事情:
当我们使用一个独立的函数语句作为 IIFE 时,我们需要用 () 包装它以使其工作 // IFFE (function a(){ console.log('Hello') }()); // I
我正在为 WCF 开发一个 Java 客户端,并且模板运行良好。我最初使用的是 eclipse 的 Web 服务客户端项目,但后来发现 android 平台不支持所需的库。当时我打算使用 ksoap,
我希望将整行变为可点击。现在行看起来像 Group Obj
我有以下标记(使用 Bootstrap 4): .resource{ border:1px solid red; } tes
#parent{ max-width:1100px; margin: auto; border: 1px solid red; padding: 40px; } #ch
我正在尝试用自定义指令包裹 Angular 带的弹出框。 弹出窗口应该能够使用由使用我的指令的人提供的自定义模板,并且该模板应该能够使用 Controller 的范围。 对于范围部分,我发现我可以将
我有一个 HTML 页面,其中一个 div 包含另一个包含数据库(聊天系统)中所有用户的 div,但是 ul li 标签没有占用父 div 的整个宽度。这是预期结果的图像:http://prntscr
我正在尝试通过套接字将包裹发送到 Android 应用程序。客户端在 libbinder(c++) 中,服务器是一个必须重建包裹的 android 应用程序。我一直在寻找解决方案有一段时间了,但我不知
当我部署一个网站(有多个入口点,许多 HTML 文件)并且主机使用构建命令时:parcel build index.html aboutme.html。部署的网站给我一个 404 错误。但是,如果我在
在 Quarkus 中,异常映射器返回的实体似乎被包装在另一个实体中。 提供一个 JAX-RS 异常映射器,例如: @Provider public class WebhookExceptionMap
如果我设置 textLayer.wrapped = YES , 如何调整大小 textLayer包含包装的文本?即,我如何获得 textLayer 的新高度? 基本上,我想要类似 -[UILabel
您好,如果类有 anchor ,我会尝试用 anchor 包裹图像。 jQuery: if ( $(".views-row:has(a)").length) { var noderef = $
所以,我以前多次使用 Parcel,我从来没有遇到过问题。 这一次它抛出了一些关于 SemVer 版本控制的愚蠢错误,我真的很想找到解决这个问题的解决方案。 我开始了新项目:安装了 npm w/npm
我将 Kotlin 与 Anko 一起使用,我想向另一个 Activity 发送玩家列表。 class Player(var name: String?) { var score: Int = 0 i
我正在尝试使用 Parcelable 通过 Activity 传递数据。这是我的代码: public class Player implements Parcelable { public stati
我是一名优秀的程序员,十分优秀!