可能是一個noob問題,但我無法理解在CSS中的定位非常好。昨天我遇到了背景和下拉菜單的問題,所以我決定從頭開始。問題依然存在。Div的位置困擾另一個divs,所以我不能點擊它們
我的h1不能處於我想要的位置,所以我表明了自己的立場:相對的,然後我可以移動它,但是因爲這樣我無法點擊我的下拉菜單甚至是標誌。只有一半。
HTML:
<link rel="stylesheet" type="text/css" href="./style2.css" />
</head>
<body>
<div id="stajl">
<ul>
<li><a href="#">Home Page </a></li><li>
<a href="#">Services <span class="arrow">▼</span></a>
<ul><li>
<a href="#">Trades </a></li><li>
<a href="#">Exchanges </a></li><li>
<a href="#">Business to Business </a></li>
</ul>
<li><a href="#">About </a></li><li>
<a href="#">Contact </a></li>
</ul>
</div>
<div id="img">
<a href="#"><img src="pfslogo2.png" /> </a>
</div>
<div id="header">
<h1>We're here to help! </h1>
</div>
</body>
</html>
CSS:由Dorvalla我的問題建立
body {
overflow-y: scroll;}
#stajl ul {
list-style-type: none;
margin:0;
padding:0;
float: right;
}
#stajl ul li:hover a{
background-color: #d7e6fa;
}
#stajl ul li {
display: inline-block;
}
#stajl ul li a {
text-decoration: none;
display: block;
padding: 15px;
color: white;
background-color: #0099cc;
}
#stajl ul ul {
display: none;
position: absolute;
margin-left: -105px;
}
#stajl ul li:hover ul {
display: block;
}
#stajl ul ul li {
display: block;
color: white;
width: 352px;
}
#stajl ul li li a:hover {
color: cyan;
}
.arrow {
font-size: 10px;
vertical-align: middle;
}
#img img {
margin: 0;
padding: 0;
height: 50px;
width: 100px;
top: 0;
left:0;
}
#header h1 {
padding: 0;
margin:0;
text-align: center;
position: relative;
top: -40px;
left: -60px;
color: #0099cc;
}
Codepen:codepen.io/anon/pen/VeXyRY
任何意見,將不勝感激!謝謝
可能這與'h1'是否帶有初始邊界頂部/底部? –
我添加了一個400px的寬度,並將其左側更改爲100px,並且對我來說工作正常 –
爲您的問題創建了一個codepen。 http://codepen.io/anon/pen/VeXyRY – Dorvalla