如何使边框边缘更靠近以消除边框内的空间

时间:2019-07-16 01:34:05

标签: html css border

我正在尝试将边框的右边缘引入,以使其更接近我的文字

我尝试更改页边距

html ...

<ul id="menu" >
    <li><a href="#introduction">Introduction</a></li>
    <li><a href="#whatyoushouldalreadyknow">What you should already know</a></li>
    <li><a href="#javascriptandjava">JavaScript and Java</a></li>
    <li><a href="#helloworld">Hello world</a></li>
    <li><a href="#variables">Variables</a></li>
    <li><a href="#declaringvariables">Declaring variables</a></li>
    <li><a href="#variablescope">Variable Scope</a></li>
    <li><a href="#globalvariables">Global variables</a></li>
    <li><a href="#constants">Constants</a></li>
    <li><a href="#datatypes">Data types</a></li>
    <li><a href="#if...elsestatement">if...else statement</a></li>
    <li><a href="#whilestatement">while statement</a></li>
    <li><a href="#functiondeclarations">Function declarations</a></li>
    <li><a href="#reference">Reference</a></li>
  </ul>

CSS ...

#menu {
  list-style: none;
    border: 1px solid black;
}

我希望右边距文字更近

1 个答案:

答案 0 :(得分:0)

您需要定义ul的宽度,以使边界更近。您可以根据需要增加或减少值

#menu {
  list-style: none;
  border: 1px solid black;
  width: 250px;
}

代码

#menu {
  list-style: none;
  border: 1px solid black;
  width: 250px;
}
<ul id="menu">
  <li><a href="#introduction">Introduction</a></li>
  <li><a href="#whatyoushouldalreadyknow">What you should already know</a></li>
  <li><a href="#javascriptandjava">JavaScript and Java</a></li>
  <li><a href="#helloworld">Hello world</a></li>
  <li><a href="#variables">Variables</a></li>
  <li><a href="#declaringvariables">Declaring variables</a></li>
  <li><a href="#variablescope">Variable Scope</a></li>
  <li><a href="#globalvariables">Global variables</a></li>
  <li><a href="#constants">Constants</a></li>
  <li><a href="#datatypes">Data types</a></li>
  <li><a href="#if...elsestatement">if...else statement</a></li>
  <li><a href="#whilestatement">while statement</a></li>
  <li><a href="#functiondeclarations">Function declarations</a></li>
  <li><a href="#reference">Reference</a></li>
</ul>
CSS...