英文:
put a header, paragraph and an image next to each other
问题
我正在尝试将一个带有H3标题的文本与图像并排放置。我已经成功将图像和文本放在一起,问题是我无法将我的H3放在文本的顶部。
以下是您提供的HTML和CSS代码片段的翻译部分:
<div id="box">
<h3>lorem ipsum</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
<img width="300" src="https://blog-media.byjusfutureschool.com/bfs-blog/2022/08/18080659/Article-Page-61.png" />
</div>
#box {
display: flex;
align-items: center;
width: 950px;
margin:auto;
margin-top: 30px;
}
#box p {
margin-right: 1em;
}
请注意,这只是代码的翻译部分,没有其他额外内容。
英文:
i am trying to put some text with h3 as a title parallel to an image
i managed to get the image and the text to do that, the problem is i cant get my h3 on top of the text
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
#box {
display: flex;
align-items: center;
width: 950px;
margin:auto;
margin-top: 30px;
}
#box p {
margin-right: 1em;
}
<!-- language: lang-html -->
<div id="box">
<h3>lorem ipsum</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
<img width="300" src="https://blog-media.byjusfutureschool.com/bfs-blog/2022/08/18080659/Article-Page-61.png" />
</div>
<!-- end snippet -->
This is what i want it to essentialy look like with the h3 as title
答案1
得分: 1
/*仅供演示*/
body{
margin-left: 22em;
}
.parent-box{
display: flex;
flex-direction: column;
align-items: center;
}
.left {
text-align: center;
}
.box {
display: flex;
align-items: center;
width: 950px;
background: black;
color: white;
}
.box > * {
margin: 1em;
}
<div class="parent-box">
<div class="box">
<div class="left">
<h3>lorem ipsum</h3>
<p>
强大、可扩展和功能丰富的前端工具包。使用Sass构建和自定义,利用预构建的网格系统和组件,使用强大的JavaScript插件将项目带到生活中。
通过npm、RubyGems、Composer或Meteor安装Bootstrap的源Sass和JavaScript文件。包管理安装不包括文档或完整的构建脚本。您还可以使用我们的npm模板存储库通过npm快速生成Bootstrap项目。当您只需要包含Bootstrap的编译CSS或JS时,可以使用jsDelivr。通过我们的简单快速启动查看它的实际效果,或浏览示例以快速启动下一个项目。您还可以选择单独包含Popper和我们的JS。
</p>
</div>
<img width="300" src="https://blog-media.byjusfutureschool.com/bfs-blog/2022/08/18080659/Article-Page-61.png" />
</div>
</div>
英文:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
/*only for demonstration*/
body{
margin-left : 22em;
}
.parent-box{
display : flex;
flex-direction : column;
align-items : center;
}
.left {
text-align:center;
}
.box {
display: flex;
align-items: center;
width: 950px;
background : black;
color : white;
}
.box > * {
margin : 1em;
}
<!-- language: lang-html -->
<div class="parent-box">
<div class="box">
<div class="left">
<h3>lorem ipsum</h3>
<p>
Powerful, extensible, and feature-packed frontend toolkit. Build and customize with Sass, utilize prebuilt grid system and components, and bring projects to life with powerful JavaScript plugins.
Install Bootstrap’s source Sass and JavaScript files via npm, RubyGems, Composer, or Meteor. Package managed installs don’t include documentation or our full build scripts. You can also use our npm template repo to quickly generate a Bootstrap project via npm.When you only need to include Bootstrap’s compiled CSS or JS, you can use jsDelivr. See it in action with our simple quick start, or browse the examples to jumpstart your next project. You can also choose to include Popper and our JS separately.
</p>
</div>
<img width="300" src="https://blog-media.byjusfutureschool.com/bfs-blog/2022/08/18080659/Article-Page-61.png" />
</div>
</div>
<!-- end snippet -->
答案2
得分: 1
以下是翻译好的内容,代码部分未翻译:
这应该可以实现:
<!-- begin snippet: js hide: false console: false babel: false -->
<!-- language: lang-css -->
body {
background: black;
color: white;
}
.box-outer {
display: flex;
flex-flow: row nowrap;
align-items: center;
width: 950px;
margin: auto;
margin-top: 30px;
}
.box-inner {
display: flex;
flex-flow: column nowrap;
align-items: center;
justify-content: center;
}
.box-inner__body {
margin-right: 1em;
text-align: center;
}
<!-- language: lang-html -->
<div class="box-outer">
<div class="box-inner">
<h3 class="box-inner__title">lorem ipsum</h3>
<p class="box-inner__body">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
</div>
<img width="300" src="https://blog-media.byjusfutureschool.com/bfs-blog/2022/08/18080659/Article-Page-61.png" />
</div>
<!-- end snippet -->
希望这对你有所帮助。
英文:
This should do the trick:
<!-- begin snippet: js hide: false console: false babel: false -->
<!-- language: lang-css -->
body {
background: black;
color: white;
}
.box-outer {
display: flex;
flex-flow: row nowrap;
align-items: center;
width: 950px;
margin: auto;
margin-top: 30px;
}
.box-inner {
display: flex;
flex-flow: column nowrap;
align-items: center;
justify-content: center;
}
.box-inner__body {
margin-right: 1em;
text-align: center;
}
<!-- language: lang-html -->
<div class="box-outer">
<div class="box-inner">
<h3 class="box-inner__title">lorem ipsum</h3>
<p class="box-inner__body">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
</div>
<img width="300" src="https://blog-media.byjusfutureschool.com/bfs-blog/2022/08/18080659/Article-Page-61.png" />
</div>
<!-- end snippet -->
答案3
得分: 0
你可以简单地将你的文本内容包裹在一个额外的div中:
<div id="box">
<div>
<h3>lorem ipsum</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
</div>
<img width="300" src="https://blog-media.byjusfutureschool.com/bfs-blog/2022/08/18080659/Article-Page-61.png" />
</div>
英文:
You can simply wrap your text content in an additional div:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
#box {
display: flex;
align-items: center;
width: 950px;
margin: auto;
margin-top: 30px;
text-align: center; /* center the inner text */
}
#box p {
margin-right: 1em;
}
<!-- language: lang-html -->
<div id="box">
<div>
<h3>lorem ipsum</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
</div>
<img width="300" src="https://blog-media.byjusfutureschool.com/bfs-blog/2022/08/18080659/Article-Page-61.png" />
</div>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论