html - 如何在这 3 个水平元素之间留出空间

标签 html css tabs alignment space

如何在顶部保留这三个元素之间的空间?

我尝试了几种方法,但当我尝试它们时,它们会跳到下一行。我已经添加了我正在尝试的代码。以及如何将宽度大小保持在 1000px?

<!doctype html>
<html>
<body>
<title>AquaSL</title>
<link rel="icon" type="image/png" href="image/asl2.png"
<head>

<style>
p {
 	display: inline-block;
 	float: left;
  }
  ul {
     list-style-type: none;
     width:33%;     
     margin: 0 auto;
     padding: 0;
     overflow: hidden;
     background-color: #339cff;
     display: inline-block;
     float: left;
     }
  li {
      float: left;
   
    }
  li a {
	
      display: block;
      color: white;
      text-align: center;
      padding: 14px 17px;
      text-decoration: none;
     }
  li a:hover:not(.active) {
      background-color: #345cff;
     }
  .active {
     background-color: #ff9333;
     }
</style>
<meta charset="utf-8">

<p><b><font color="white" size="+3">M Y  W E B</font></b></p>
<body>
<ul>
  <li><a class="active" href="#home">HOME</a></li>
 <li><a href="#news.html">NEWS</a></li>
 <li><a href="page2.html">Page 2</a></li>
 <li><a href="page3.html">page3</a></li>
 <li><a href="#page4.html">page4</a></li>
 <li><a href="#about us.html">ABOUT US</a></li>
</ul>

							

<img src="image/facebook-icon.png" width="54" height="55">
</body>
 <body background="image/background2.jpg"
 <br>
 <h5 style="position: fixed; bottom: 0; width:100%;text-align: center">
 <font color="yellow"><strong> Copyright © MY WEB 2016 All Rights Reserved.
 </strong></font></h5>
<img src="/image/strip.jpg" style="width:100%;">
 </body>
</html>

我要留空格的地方如下图所示:

最佳答案

你只需要在中间项添加边距()

<!doctype html>
<html>
<body>
<title>AquaSL</title>
<link rel="icon" type="image/png" href="image/asl2.png"
<head>

<style>
p {
 	display: inline-block;
 	float: left;
  }
  ul {
     list-style-type: none;
     width:33%;     
     margin: 0 10px;
     padding: 0;
     overflow: hidden;
     background-color: #339cff;
     display: inline-block;
     float: left;
     }
  li {
      float: left;
   
    }
  li a {
	
      display: block;
      color: white;
      text-align: center;
      padding: 14px 17px;
      text-decoration: none;
     }
  li a:hover:not(.active) {
      background-color: #345cff;
     }
  .active {
     background-color: #ff9333;
     }
</style>
<meta charset="utf-8">

<p><b><font color="white" size="+3">M Y  W E B</font></b></p>
<body>
<ul>
  <li><a class="active" href="#home">HOME</a></li>
 <li><a href="#news.html">NEWS</a></li>
 <li><a href="page2.html">Page 2</a></li>
 <li><a href="page3.html">page3</a></li>
 <li><a href="#page4.html">page4</a></li>
 <li><a href="#about us.html">ABOUT US</a></li>
</ul>

							

<img src="image/facebook-icon.png" width="54" height="55">
</body>
 <body background="image/background2.jpg"
 <br>
 <h5 style="position: fixed; bottom: 0; width:100%;text-align: center">
 <font color="yellow"><strong> Copyright © MY WEB 2016 All Rights Reserved.
 </strong></font></h5>
<img src="/image/strip.jpg" style="width:100%;">
 </body>
</html>

关于html - 如何在这 3 个水平元素之间留出空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39968916/

相关文章:

PHP 将每个段落拆分为数组

html - 在 HTML/CSS 中加载自定义中文/日文字体是否有比@font-face 更快的方法?

HTML+CSS div 容器

android - 选项卡布局 : How to add swipe AND onClick to switch tabs

html - 覆盖第三方输入中的占位符值

javascript - Angular 下拉菜单消失

javascript - 我可以选择导航链接中的第二个链接吗

CSS 布局在 iPhone/iPad 上向右移动?

python - 如何将行号从 Python traceback 发送到 vim?

带有选项卡保存状态的 Android ViewPager