简体   繁体   English

无法使网站上的文本响应

[英]Unable to make the text responsive on website

I'm having issues in making a piece of text on my website, which will be part of the navigation system, become responsive.我在我的网站上制作一段文本时遇到问题,该文本将成为导航系统的一部分,变得响应。 Currently, the text is just sitting there and will not move when I readjust my browser.目前,文本只是坐在那里,当我重新调整浏览器时不会移动。

Here is my HTML:这是我的 HTML:

<div id="apDiv1">
<div class="wrapper1">
  <h2>Home</h2>
</div></div>

Here is my CSS:这是我的 CSS:

.wrapper1{

width:100%;
max-width:960px;
margin:0 auto;

}

You expect your text to move when you change the size of your browser window.当您更改浏览器窗口的大小时,您希望文本移动。

However, if the text is left adjusted (as you your case), it will always be on the left, regardless of the window size.但是,如果文本向左调整(根据您的情况),则无论窗口大小如何,它都将始终位于左侧。 So you should not expect it to "move".所以你不应该期望它“移动”。

Are you trying to center the div on-screen?您是否试图将 div 居中显示在屏幕上? I'm not sure what you mean by move the text.我不确定你说的移动文本是什么意思。 If you want to center the div ".wrapper1", add position: relative to it.如果要使 div“.wrapper1”居中,请添加position: relative到它。

If you want to center the text, make it text-align: center;如果要使文本居中,请将其text-align: center;

Did you include the css file correctly in your html?您是否在 html 中正确包含了 css 文件?

The following works as expected.以下按预期工作。 You can base your debugging on that:您可以基于此进行调试:

<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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM