html - 如何在不弄乱边框的情况下将 <div> 保留在页眉内?

标签 html css

我正在尝试为自己创建一个示例页面,这样我就永远不会忘记基础知识,但是出现了一个问题,我将 的边框设置为 border: 5px一开始是灰色的;,但现在

出现在页眉之外,我该如何解决?如果可能的话,为什么会这样?

你能帮忙吗?

提前致谢。

我在 liveweave 上的页面:http://liveweave.com/yRuhbM ;

html{font-family:Courier;}
button{width: 50%;margin: 4%; border-radius: 5px;height: 10.6%;} /*Any button is gonna get those properties, if you don't want it, set it below it*/
label{width: 50%;margin: 4%;}
div{width: 100%;height:20%; color: white; border-radius: 0px;text-align: center;background-color: gray;}
a{text-decoration: none; color: black;border: 5px outset gray;}

.left{float:left;width: 20%;height: 60%;}
.right{float: right;width: 20%; height: 60%;}

#header{margin:auto;top:1px;}
#footer{clear:both;margin:auto;bottom: 10px;}
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Page Testing</title>
</head>
<body>
  <div id="header">
    <div id="tab">
      
        <a href="http://www.google.com">Home</a>
        <a href="http://www.google.com">Contact Us</a>
        <a href="http://www.google.com">About</a>
 
    </div>
  </div>
  <div class="left">
    <button>Button 1</button>
    <button>Button 2</button>
    <button>Button 3</button>
    <button>Button 4</button>
    <button>Button 5</button>
    <button>Button 6</button>
  </div>
  <div class="right">
    <label>blah</label>
    <label>blah</label>
    <label>blah</label>
    <label>blah</label>
    <label>blah</label>
    <label>blah</label>
    <label>blah</label>
    <label>blah</label>
  </div>
  <div id="footer"></div>
</body>
</html>

最佳答案

添加这个

a{
text-decoration: none; 
display:inline-block; 
color:black;
border: 5px outset gray;
}

Fiddle

关于html - 如何在不弄乱边框的情况下将 <div> 保留在页眉内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30597621/

相关文章:

html - 使用 AutoIt 从 iframe 获取表单名称

html - 如何使用百分比作为参数在 HTML 中调整图像大小?

javascript - 加载一个 .html 页面,其中应包含 .php 文件中的一些数据

html - 向左浮动的CSS

html - IE 11 错误 - 表格内标签内的图像

javascript - 像素精确的文本对齐

css - Internet Explorer 中::before 伪元素的位置和大小

CSS - 无法更改 DIV 的背景颜色 - WooCommerce 产品描述

jQuery 显示 Div 以清除 <li>

javascript - 鼠标悬停后div发生变化,div不显示