简体   繁体   English

如何在 html 中在一行中显示 2 个短语,一个居中对齐,另一个右对齐?

[英]How to display 2 phrases in a single line , one center aligned ,the other right aligned in html?

I want to display the following heading line in HTML:我想在 HTML 中显示以下标题行:

                         Hello World                  HTML Example

"Hello World" is center aligned while "HTML Example" is right aligned. “Hello World”居中对齐,而“HTML Example”右对齐。 Which HTML element should I use?我应该使用哪个 HTML 元素?

I've tried using span element and the display:inline css style but the two phrases always display in two separate lines.我试过使用 span 元素和 display:inline css 样式,但是这两个短语总是显示在两个单独的行中。

HTML <h4 align="center" > Hello World <span align="right" > HTML Example </span></h4> HTML <h4 align="center" > Hello World <span align="right" > HTML Example </span></h4>

Hopefully it's what you're trying to achieve:希望这是您想要实现的目标:

 <h4 align="center"> Hello World <span style="float:right;"> HTML Example </span></h4>

Good luck!祝你好运!

<h4 align="center" ><span style="float:left;margin-left:30%"> Hello World</span> <span align="right" style="float:right;margin-right:30%"> HTML Example </span></h4>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使两个对象水平对齐(一个在另一个的右侧)并居中放置一个? - How can I have two objects aligned horizontally (one to the right of the other) and center the left one? 如何在同一行上有两个DIV,一个不带HTML表格,一个左对齐,一个右对齐? - How can I have two DIV s on the same line , one aligned to the left and one aligned to the right without an HTML table? 如何使用 HTML 和 CSS 将图像定位在居中对齐的标题右侧 - How to position an image to the right of a center aligned title with HTML & CSS 如何让文本右对齐,但 div 居中对齐? - How can I have text aligned right, but the div aligned center? 如何将这两个放在同一行? (一个居中,一个右对齐) - how to put these two on the same line? (one centered, one right aligned) 我该如何布置两个 <div> 在一行上,并且其中一个居中对齐(相对于整行),而另一个居右对齐? - How can I lay out two <div>s on one line, and have one centre-aligned (relative to the entire line) and the other right-aligned? 单行文字未与div中心对齐 - One-line text not aligned to center of div 如何在表格单元格(td)中定位元素,使得一个元素左对齐而另一个元素对齐? - How can I position elements within a table cell (td) such that one element is left aligned and the other right aligned? HTML 当对齐不起作用时,如何从左到右更改对齐? - HTML How to change aligned from left to the right, when aligned not working? 如何居中对齐10列HTML页面? - How to center aligned 10 columns HTML page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM