[英]Unable to make the text responsive on website
我在我的網站上制作一段文本時遇到問題,該文本將成為導航系統的一部分,變得響應。 目前,文本只是坐在那里,當我重新調整瀏覽器時不會移動。
這是我的 HTML:
<div id="apDiv1">
<div class="wrapper1">
<h2>Home</h2>
</div></div>
這是我的 CSS:
.wrapper1{
width:100%;
max-width:960px;
margin:0 auto;
}
當您更改瀏覽器窗口的大小時,您希望文本移動。
但是,如果文本向左調整(根據您的情況),則無論窗口大小如何,它都將始終位於左側。 所以你不應該期望它“移動”。
您是否試圖將 div 居中顯示在屏幕上? 我不確定你說的移動文本是什么意思。 如果要使 div“.wrapper1”居中,請添加position: relative
到它。
如果要使文本居中,請將其text-align: center;
您是否在 html 中正確包含了 css 文件?
以下按預期工作。 您可以基於此進行調試:
<html>
<head>
<style type="text/css"> .wrapper1 {color:red; text-align:center; width:100%;} </style>
</head>
<body>
<div id="haha">
<div class="wrapper1">
<h2>Hello World.</h2>
</div>
</div>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.