重叠的div具有固定和相对的位置

时间:2017-03-22 06:39:50

标签: html css position

我有一个名为div的{​​{1}},其中包含多个子container元素。在这些子div中,名为div的最顶层的top_barposition: fixed,其余的position: relativediv。问题是具有相对定位的top:150px s与具有固定定位的div重叠。 jsfiddle概述了这个问题。我能够通过添加$ie = new-object -com internetexplorer.application $ie.visible=$true $ie.navigate('https://google.co.in') while($ie.ReadyState -ne 4) { Write-Host "dom is loading" waiting start-sleep -M 100 } ($ie.Document.IHTMLDocument3_getElementsByTagName('a')|where-object{$_.innerText -eq "मराठी"}).click() 来纠正这个问题,但这感觉更像是一个黑客。有一个更好的方法吗?

2 个答案:

答案 0 :(得分:1)

如果你想要这个动态,你可以查看下面提到的链接:

https://jsfiddle.net/06vzbuf0/2/

我已使用jQuery来解决此问题。

答案 1 :(得分:0)

padding-top:120px;添加到container,将top:0;添加到top_bar,以下div不会叠加到上边栏。

html, body {
    height:100%;
}

.container {
    text-align: center;
    width:100%;
    margin:0%;
    padding:120px 0 0;
    color: dodgerblue;
}

.top_bar{
    box-shadow: 0px 5px 5px #DDD;
    position: fixed; 
    z-index: 10000;
    opacity: .95;
    background-color:#f9f9f9;
    width:100%;
    top:0;
}

.mugoogle{
    font-size: 22px;
    font-family: Arial;
    margin: 10px auto; 
}

.mugoogle a, .tab_results a {
    text-decoration:none;
    -webkit-transition:all .3s ease;
    -ms-transition:all .3s ease;
    transition:all .3s ease;
}

.mugoogle a:hover{
    color: #aaa;
}

.tab_results a:hover {
    text-decoration:underline;
    color: #000
}


.textbox{
    margin: 0px auto; 
    height:30px;
    width:60%;
}


.rounded { 
	border-radius:5px; 
	-moz-border-radius:5px; 
	-webkit-border-radius:5px; 
}

/* h4{
    -moz-transition: all .5s;
    -webkit-transition: all .5s;
    transition: all .5s;
}
 */
input[type="submit"] {
height: 30px;
}

input[type="text"] {
    border: 1px solid #ccc;
    margin: 10px;
    padding: 5px;
    -moz-transition: all .5s;
    -webkit-transition: all .5s;
    transition: all .5s;
}

input[type="text"]:focus {
  border-color: #66afe9;
  outline: 0;
  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
  box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
}  

.button {
	display: inline-block;
	outline: none;
	cursor: pointer;
	text-align: center;
	text-decoration: none;
    width: 40px;
	font: 14px/100% "Century Gothic", Arial, Helvetica, sans-serif;
	/* padding: .5em 2em .55em; */
	text-shadow: 0 1px 1px rgba(0,0,0,.3);
	-webkit-border-radius: .5em; 
	-moz-border-radius: .5em;
	border-radius: .5em;
	-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
	-moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
	box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.button:hover {
	text-decoration: none;
}
.button:active {
	position: relative;
	top: 1px;
}

.blue {
	color: #d9eef7;
	border: solid 1px #0076a3;
	background: #0095cd;
	background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5));
	background: -moz-linear-gradient(top,  #00adee,  #0078a5);
	filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5');
}
.blue:hover {
	background: #007ead;
	background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e));
	background: -moz-linear-gradient(top,  #0095cc,  #00678e);
	filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#0095cc', endColorstr='#00678e');
}
.blue:active {
	color: #80bed6;
	background: -webkit-gradient(linear, left top, left bottom, from(#0078a5), to(#00adee));
	background: -moz-linear-gradient(top,  #0078a5,  #00adee);
	filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee');
}

.project_data{
    text-align:left;
    width: 1000px;
    position:relative;
    padding: 5px;
    word-wrap:break-word;
    margin:0 auto;
    font-family: Calibri;
    font-size: 18px;
    color: #555;
}
<div class = "container">
<div class = "top_bar">
<h4 class = 'mugoogle'>
<a href = '/search/'>
muGoogle
</a>
</h4>
<form  class="form-wrapper" method = "GET" action = "{% url 'doc_scorer'%}">
    <input type="text" name = 'query' class="textbox rounded" placeholder="Search docs related to..." required>
    <input type="submit" class="button blue" value="&#128270;">
</form>
<br>
</div>
<br>

<div class = 'project_data project_name'>
<strong>Project name: </strong>
</div>

<div class = 'project_data scq_title'>
<strong>SGQ: </strong>
</div>

<div class = 'project_data situation'>
<strong>Situation: </strong>
</div>

<div class = 'project_data future_state'>
<strong>Future State: </strong>
</div>

<div class = 'project_data complications'>
<strong>Complications: </strong>
</div>

<div class = 'project_data questions'>
<strong>Questions: </strong>
</div>

<div class = 'project_data data'>
<strong>Data: </strong>
</div>

<div class = 'project_data name'>
<strong>Name: </strong>
</div>
<br>
<br>
</div>