有没有办法在 "center-left" 上设置此 header 文本?
Is there a way to set this header text on the "center-left"?
有没有办法将 header 文本设置为 "center-left" 而不是居中或左侧。
提前致谢。
----------------200px---------------->
<!DOCTYPE html>
<html>
<head>
<title>HTML5, CSS3 and JavaScript demo</title>
</head>
<body>
<div style="background-color:red;width:200px;text-align:center"> <!--"text-align: center-left"-->
<div style="">
header
</div>
</div>
</body>
</html>
首先,或者您将文本居中或放在左侧。别无他法。
如果你想做利润,使用 div 这样的:
<div style="width: 50%; margin: 0 auto; text-align:left">
your text
</div>
50%就是例子,试试吧。您还可以使用边距或填充 属性,阅读相关内容。
您是否尝试将其置于屏幕左侧 50% 的中心位置?如果是这样,就是这样:
.left-center {text-align: center; width: 50%;}
<div class="left-center">Left Center</div>
或者如果它在屏幕的 1/4
th,那么这会起作用:
.left-center {text-align: center; width: 25%;}
<div class="left-center">Left Center</div>
希望对您有所帮助;
.header{
margin-left:-25%;
}
<!DOCTYPE html>
<html>
<head>
<title>HTML5, CSS3 and JavaScript demo</title>
</head>
<body>
<div style="background-color:red;width:200px;text-align:center"> <!--"text-align: center-left"-->
<div style=""class="header">
header
</div>
</div>
</body>
</html>
有没有办法将 header 文本设置为 "center-left" 而不是居中或左侧。
提前致谢。
----------------200px---------------->
<!DOCTYPE html>
<html>
<head>
<title>HTML5, CSS3 and JavaScript demo</title>
</head>
<body>
<div style="background-color:red;width:200px;text-align:center"> <!--"text-align: center-left"-->
<div style="">
header
</div>
</div>
</body>
</html>
首先,或者您将文本居中或放在左侧。别无他法。 如果你想做利润,使用 div 这样的:
<div style="width: 50%; margin: 0 auto; text-align:left">
your text
</div>
50%就是例子,试试吧。您还可以使用边距或填充 属性,阅读相关内容。
您是否尝试将其置于屏幕左侧 50% 的中心位置?如果是这样,就是这样:
.left-center {text-align: center; width: 50%;}
<div class="left-center">Left Center</div>
或者如果它在屏幕的 1/4
th,那么这会起作用:
.left-center {text-align: center; width: 25%;}
<div class="left-center">Left Center</div>
希望对您有所帮助;
.header{
margin-left:-25%;
}
<!DOCTYPE html>
<html>
<head>
<title>HTML5, CSS3 and JavaScript demo</title>
</head>
<body>
<div style="background-color:red;width:200px;text-align:center"> <!--"text-align: center-left"-->
<div style=""class="header">
header
</div>
</div>
</body>
</html>