- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试了解 html 的基础知识,我编写了这段小代码,但我不知道如何使正文内容的图像左侧。
<html>
<img src="https://previews.123rf.com/images/alvincadiz/alvincadiz1604/alvincadiz160400358/56426319-vector-illustration-of-smiley-emoticon-sad-face.jpg" alt="Smiley face" style="float:left;width:42px;height:42px;">
<style>
body {
width: 15em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
<body>
“People say nothing is impossible, but I do nothing every day."
<p>– A. A. Milne</p>
</body>
</html>
你可以从这里看到页面:page
因此您可以看到图像已经取代了正文内容,当您删除图像 block 并再次运行它时,您会注意到正文内容返回到它的实际位置。
我想要这样:
那么如何在不取代正文内容的情况下将 float 图像放在正文内容的左侧?
最佳答案
如果我没有正确理解您的问题,虽然图像位于左侧,但您希望文本正文保持内联。
是这样的吗? https://www.w3schools.com/code/tryit.asp?filename=GAUA12AA769P
<style>
.post-container {
margin: 20px 20px 0 0;
overflow: auto;
}
.post-thumb {
float: left;
}
.post-thumb img {
display: block;
width: 42px;
height: 42px;
}
.post-content {
margin-left: 50px;
}
</style>
<body>
<div class="post-container">
<div class="post-thumb"><img src="https://previews.123rf.com/images/alvincadiz/alvincadiz1604/alvincadiz160400358/56426319-vector-illustration-of-smiley-emoticon-sad-face.jpg" /></div>
<div class="post-content">
<p>“People say nothing is impossible, but I do nothing every day."</p>
<p>– A. A. Milne</p>
</div>
</div>
</body>
最值得注意的是,我在图像中添加了 display: block;
并在文本内容上设置了 margin-left: 50px;
。
编辑 https://www.w3schools.com/code/tryit.asp?filename=GAUA575L092N
<style>
body {
width: 15em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
.post-container {
margin: 20px 20px 0 0;
overflow: auto;
}
.post-thumb {
margin-top: 30px;
float: left;
}
.post-thumb img {
display: block;
width: 42px;
height: 42px;
}
.post-content {
margin-left: 50px;
}
</style>
<body>
<div class="post-container">
<div class="post-thumb"><img src="https://previews.123rf.com/images/alvincadiz/alvincadiz1604/alvincadiz160400358/56426319-vector-illustration-of-smiley-emoticon-sad-face.jpg" /></div>
<div class="post-content">
<p>“People say nothing is impossible, but I do nothing every day."</p>
<p>– A. A. Milne</p>
</div>
</div>
</body>
我已经添加了主体样式。图像上有一个 margin-top
将其向下推到文本的中心,但是如果您希望图像出现在文本的左上角,只需删除 margin-top : 30px
来自 .post-thumb
类。
更好的选择是使用像 flexbox 这样的东西然而,为此。
编辑 2:
我已经更新了我的代码以使用 flexbox,这是一个更加简洁明了的解决方案。您可以阅读更多关于 here 的信息.
"This is an approach to layout creation, alignment of elements and distribution of extra space.
Flex stands for flexible, adaptive. Flexboxes are thus flexible elements of the layout. One of the main advantages of flexbox is the ability to fill extra space without the need to use Javascript."
https://www.w3schools.com/code/tryit.asp?filename=GAUAC9HBCS2S
<style>
body {
width: 15em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
.flex-item {
display: flex;
align-items: center;
}
.flex-item img {
flex-grow: 0;
flex-shrink: 0;
width: 42px;
height: 42px;
margin-right: 15px;
}
</style>
<body>
<div class="flex-item">
<img src="https://previews.123rf.com/images/alvincadiz/alvincadiz1604/alvincadiz160400358/56426319-vector-illustration-of-smiley-emoticon-sad-face.jpg">
<div>
<p>“People say nothing is impossible, but I do nothing every day."</p>
<p>– A. A. Milne</p>
</div>
</div>
</body>
关于html - 如何在正文内容的左侧制作 float 图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59706089/
我在休息服务中有以下方法: @POST @Path("/create") @ResponseStatus(HttpStatus.CREATED) @Consumes(M
这个问题不太可能对 future 的访客有帮助;它只与一个小的地理区域、一个特定的时刻或一个非常狭窄的情况相关,通常不适用于互联网的全局受众。如需帮助使这个问题更广泛地适用,visit the hel
我有这样的弹出框: Speelland And here's some amazing content. It's very engaging. Right? Meer
我正在开发一个 firefox 插件,我正在收听这样的 http 响应: var observerService = Components.classes["@mozilla.org/observer
我正在使用 jqtouch 制作一个移动网站。我还在网站中实现了图库图像 slider ,但是当图库放在我需要的位置时(在 之间,图像不会显示。 修补了几个小时后,删除了 display: none
为了在 iPad 上的 Safari 上显示视差效果,我采用了以下 CSS 规则: body:after { content: ""; position: fixed; top
我想在通过 excel VBA 创建的电子邮件正文中插入一个链接。链接每天都在变化,所以我把它的值放在单元格 B4 中。但是,我找不到正确的方法来发送带有该链接的电子邮件。 这是我正在使用的代码: P
我正在尝试使用具有非常大主体的 Postman 执行 POST 请求。只有一个 JSON 字段非常大,我想知道是否可以从 Postman 的文件中加载该字段? { "field1": {
这个问题是针对 SoapUI 5.2.1 社区版的: 我有一个包含变量的 JSON 主体的 POST 请求。 我总是能够通过单击“原始”选项卡以查看请求进行或将发送到服务器来验证这些参数是否采用正确的
我有这个按钮,单击该按钮会打开 Outlook,其中包含我提供的详细信息。我还有一个 TEXTAREA,其中包含某些文本。我正在寻找一种方法让此文本出现在我的 Outlook 正文中。这可以做到吗?请
我知道错误消息是不言自明的,我们无法多次读取消息正文。这里我使用AOP(面向方面编程)来进行审计日志。 [AuditServiceMethod(AttributePriority = 0)] [F
我在 grails 3.3.3 中编写自定义验证器(命令)时遇到了一些问题。具体来说,我正在尝试验证其正文由项目列表组成的 POST 请求。这就是我所拥有的... 命令: class VoteComm
这个问题在这里已经有了答案: json.Marshal(struct) returns "{}" (3 个回答) JSON and dealing with unexported fields (3
我想清理很多邮件的 HTML 正文,它们有点脏(取自 Gmail 发送的电子邮件):有很多嵌套 ,不需要的字体更改等我想清理它并只保留 , , , , , 仅此而已(可能还有 或一些 ,
我正在使用 Accordion 功能在我的模块中添加端口详细信息。我只想在水平方向上显示正文内容。请看下面的 fiddle 。 html, body { background-color:#e
我的 HTML 正文中有这个: loaded y&EACUTE;t. 使用 JavaScript 我有这个: $( document ).ready(function() { document.bod
我对图表有很大的疑问。我试图在谷歌图表中显示一些 json 值,但我总是会出错。从 JSON 正文中,我只需要图表上个月的“全部购买”和“日期”。我见过的所有例子,他们已经有了一个静态的自定义 Jso
我的应用程序的功能之一涉及用户填写三个单独的文本字段(预订名称、客人和日期),然后使用文本编辑器通过短信发送这些字段中的文本。我无法将这些 View 中的文本放入正文中。这是我的代码: - (IBAc
我正在开发一个 HTA,它应该对 onunload 事件进行一些最终修改。该事件似乎没有被触发。 该事件是否仍受支持?是否有 IE 事件可以知道页面何时关闭? 我检查了一下(JavaScript bo
我正在尝试将以下图像添加为网站内容的背景: http://webbos.co/vibration/wp-content/themes/vibration-child-theme/images/back
我是一名优秀的程序员,十分优秀!