单独移动文本 div 标签

发布于 2024-09-14 11:30:47 字数 520 浏览 2 评论 0原文

我正在尝试移动标题旁边的文本,但它无法使用边距工作 - 当我尝试移动它时,所有文本框都会移动,即使每个文本框都是单独的 div 标签。

这是我这部分的代码,

<body>
<div id="wrapper">
  <div id="header">
    <h4><strong>Qtek Australia</strong></h4>
    <div id="home">Home</div>
    <div id="Aboutus">About us</div>
    <div id="Contactus">Contact us</div>
     <div id="Location">Location</div>

  </div>

我正在尝试将主页、关于我们、联系我们和位置移到标题“Qtek Australia”的右侧,请帮助

I am trying to move text next to my header, but it is not working using margins - when i try to move it all the text boxes move, even though each text box is a seperate div tag.

Here is my code for this part

<body>
<div id="wrapper">
  <div id="header">
    <h4><strong>Qtek Australia</strong></h4>
    <div id="home">Home</div>
    <div id="Aboutus">About us</div>
    <div id="Contactus">Contact us</div>
     <div id="Location">Location</div>

  </div>

i am trying to move the home, about us, contact us and location to the right of the header "Qtek Australia", please help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

西瓜 2024-09-21 11:30:47

您可以尝试将 h4 包装在另一个 div 中并将其放置在您想要的位置。
如果这是您已经尝试过的方法,另一种方法可能是将您想要放置在左侧的三个 div 包装在一个 div 中,将其他四个 div 包装在另一个 div 中,然后在这两个 div 周围移动。即使这样做可能会导致感染,但它应该更容易。

You can try wrapping the h4 in another div and placing it where you want.
If this is the way you already tried, another way could be wrapping the three div you want to place on the left in one div, the other four in another and move around these two divs. It should be easier, even if you can get divitis doing so.

小帐篷 2024-09-21 11:30:47

我会说你的文档语义相当模糊。您可能不需要在标题中使用 STRONG - 可以想象您确实想强调其中表达的思想,但我怀疑您只是想让标题显得更粗。使用 CSS 来实现这一点,如: h4 {font-weight:bold;字体大小:14em;}

也可以想象,您的页面从某个主题的第四级开始进行导航是最有意义的,但这可能性很小;在绝大多数情况下,导航将存在于更高的位置 - 在 h1 或 h2 下。

如果它是无序列表,您的导航本身会更加连贯。

<ul>
    <li>Home</li>
    <li>About Us</li>
    ...
</ul>

这还有一个优点,即允许您将导航元素作为一组和单独设置样式。

您可能不需要将元素包装在所有这些 div 中。 HTML 中的大多数元素都是容器 - 标题、列表、段落,几乎所有内容都可以自行设置样式 - 包括定位和移动。

例如,将导航列表定位到 h4 右侧的一种方法是使用“display:inline”或“float:left”设置 h4 的样式,这会将以下元素(列表)置于同一行。有很多不同的方法可以实现这种定位,甚至不清楚这是否是您所追求的。

澄清你的意思;如果您发布您正在使用的任何 CSS 或 JavaScript,这将会有所帮助。

I will say that your document semantics are quite vague. You probably don't need to use STRONG inside your heading - it's conceivable that you really mean to emphasize the thought expressed in it, but I suspect that you only want the heading to appear bolder. Use CSS to achieve that, as in: h4 {font-weight:bold; font-size: 14em;}.

It's also conceivable that your page makes the most sense with the navigation starting at the fourth level of some topic, but it's highly unlikely; in the vast majority of cases, the navigation would exists higher up - under h1 or h2.

Your navigation itself would be more coherent if it was an unordered list.

<ul>
    <li>Home</li>
    <li>About Us</li>
    ...
</ul>

This also has the advantage of allowing you to style the navigation elements both as a set and individually.

You probably don't need to be wrapping your elements in all those divs. Most elements in HTML are containers - headings, lists, paragraphs, just about everything can be styled - including positioning and moving - by itself.

For instance, one means of positioning the navigation list to the right of the h4 would be to style the h4 with "display:inline", or "float:left", which would bring the following element (the list) onto the same line. There's a lot of different ways to go about that kind of positioning, and it's not even clear that this is what you're after.

Clarify what you mean; and it would help if you posted whatever CSS or JavaScript you're using.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文