HTML / CSS的新手,尝试居中和显示:内联在一起

时间:2013-03-29 03:40:59

标签: html css center

我是新手和编码。请帮忙!我准备掏出我的眼睛了。

我正在尝试在页面中居中显示消息。它说“欢迎来到蜡染别墅”。该页面将使用两种语言,英语和缅甸语。我想包含一个在页面之间交换的链接。我希望“欢迎来到Batik别墅”居中,英语/缅甸语链接位于它的右侧。我不希望它在较低的线上。我一直在寻找几个小时,我无法弄明白。

这是我的文字。          

<div id=Jim; style="font-family: Georgia;
display:inline">

<p style="border: blue groove;
margin: 0;
margin: auto; 
text-align:center;
color:black;
background-color: white; 
width: 600px;
border-width:10px;">

Welcome to Batik Villa!
</p>
</div>

<a href="b"> English </a>  
<a href="a"> Myanmar </a>

</body>
</html>

请帮忙!或者告诉我是否不可能!

5 个答案:

答案 0 :(得分:1)

http://jsfiddle.net/pD5Vw/1/

<div id=Jim; style="font-family: Georgia;">

<p style="border: blue groove;
 margin: 0;
 margin: auto; 
 text-align:center;
 color:black;
 background-color: white; 
 width: 70%;
 float:left;
 border-width:10px;">
 Welcome to Batik Villa!  
</p>
 <span style="float:right; display:inline-block; padding-top:5px;"><a href="b"> English       </a>  
 <a href="a"> Myanmar </a></span> 

</div>

答案 1 :(得分:1)

你的意思是这样的,还是我错过了什么?:http://jsfiddle.net/SUxmb/1/

div.wrapper{
    margin:50px auto;
    width:250px;
    background:#ddd;
    padding:20px;
    overflow:hidden;
}

div#welcome{
    float:left;
}

div#lang{
    float:right;
}

如果您想要一个带有指示&#39; xyz&#39;的边框的居中文本框,请使用http://jsfiddle.net/SUxmb/8/。在同一条线上,但是在右边(不在中心,而不是在同一个框或边框中)

div#welcome {
    margin:50px auto;
    width:250px;
    background:#ddd;
    position:relative;
    height:50px;
    line-height:50px;
    text-align:center;
}

div#lang {
    position:absolute;
    background:#ccc;
    left:100%;
    top:0px;
    height:50px;
    padding:0px 20px;
}

div#lang a{
    padding:0px 5px;
}

答案 2 :(得分:0)

<center>
<a href="b"> English </a>  
<a href="a"> Myanmar </a>
</center>

???

答案 3 :(得分:0)

对于div id =“Jim”将宽度设置为60%并使用text-align:right,这将使文本看起来居中并将div浮动到左侧。为按钮创建一个div并将其向右浮动。

<div style="float: right;">
<a href="b"> English </a>  
<a href="a"> Myanmar </a>
</div>

答案 4 :(得分:0)

  1. 对于#Jim,请移除display: inline,(默认为display:block);这会自动占用其容器的宽度。然后给它text-align: center
  2. 对于p,请指定display: inline,以便它不会将链接推到新线上。
  3. 整体代码可以在jsFiddle看到。