I have two divs, the one acts as a panel, the second is a mapview (openlayers)
The panel is hidden at the start, and only shows up on a click. however, when the panel appears, the mapdiv gets pushed to the right and overlaps with another div. how can I prevent that?
What I basically want is that the panel appears on top of the map.
This is my code:
<!-- TOOLBAR/PANEL -->
<div class="waveCreatorPanel" style="visibility:hidden; display:none;">
<ul>
<li><a id="createWave_addStation"data-role="button">Station hinzufügen</a></li>
<li><a id="createWave_addItem" data-role="button" disabled="disabled">Item hinzufügen</a></li>
<li><a id="createWave_saveWave"data-role="button">Wave speichern</a></li>
</ul>
</div><!-- /footer -->
<!-- MAP -->
<div class="geosurfmap" id="map" data-role="content" style="z-index:1"></div>
The CSS:
.waveCreatorPanel {
float:left;
}
.geosurfmap {
padding:25px;
margin:25px;
width:80%;
float:left;
}
absolute positioning for one or both of these will definetly solve this
<div class="panel" style="visibility:hidden; display:none; position:absolute; left:0px; top:0px;">
<ul>
//stuff here
</ul>
</div>
<!-- MAP -->
<div class="map" id="map" data-role="content" style="position:absolute; left:100px; top:100px;"></div>
styling could be applied with css stylesheet attached , or inline - since you already have a style attribute in your div's I just added an example of how to set absolute - adjust left and top to where you actually want them
When you originally had visibility:hidden; display:none; that is leaving the other div to be positioned relative , with nothing around it. It is the same as actually not having it in HTML at all , then when it changes to become visible everything that was positioned relative has to be adjusted , absolute positioning will fix this
Another Thing: you're title says "Parent Div" - this in NOT a parent div of the div that is getting shifted around , it is actually adjacent. You would not be having this problem if it was actually a parent. But then again the parent starts as hidden , so everything in it would be hidden
Some possible solutions depending on the rest of your page:
position:absolute
z-index
You could wrap the map and panel divs in another div and give that the minimum required width (were the panel div to be visible). Secondly you would float the map div right
<div id="wrapper">
<div class="panel"></div>
<div class="map"</div>
</div>
<style>
#wrapper {
min-width: 500px;
}
#wrapper .panel {
position:relative;
float: left
}
#wrapper .map {
position: relative;
float:right;
}
</style>
EDIT
To clarify my point I have made a fiddle for you
You can set the panel class to display:none or block to see that the map div now does not displace anymore as a result
Related
I'm new to HTML did some research in w3school but not clear about how put image on this three different position on this background image in one div. I marked the position I need to put the image. The div will cover entire page in webkit and moz based browser. Consider any width and height of div. How you fixed position with respect to your considered width and height. I can't put background image to entire html or body or etc. It have to in one div or section only.
<div id="page1" style={"background:url('http://s27.postimg.org/r5v9ymd77/pg3bgl.png');background-size:cover;}">
<span class="">Page 1</span>
<div class="">
<!-- Content Goes Here -->
</div>
</div>
This is a very simple way to achieve that using relative CSS positioning.
You can use a background div, and inside of it place the divs you need.
*{
margin:0;
padding:0;
}
.background{
background:url('http://lorempixel.com/1000/1600/nature');
background-size:cover;
height:100vh;
width:100%;
}
.img1,
.img2,
.img3{
position:relative;
width:300px;
height:150px;
background:url('http://placehold.it/300x150');
}
.img1{
top:20px;
left:350px;
}
.img2{
top:150px;
left: 20px;
}
.img3{
top:350px;
left:150px;
}
<div class="background">
<div class="img1"></div>
<div class="img2"></div>
<div class="img3"></div>
</div>
If you wish you can have a look at multiple images backgrounds, here: http://www.w3schools.com/css/css3_backgrounds.asp
i would set up the html like this:
<div id="navbar">
<div id="image1" style=""></div>
<div id="image2" style=""></div>
<div id="image3" style=""></div>
<div>
<p>Text in navbar</p>
</div>
</div>
For each id "imageX" you could set a background-image then. And with display: inline-block, width and position you can put them where you want.
There are multiple ways to achieve that.
You can set the position of your div to absolute and adjust it to the position you'd like it to be
#div1 {
position : absolute;
left : 100px;
top : 200px;
}
You can also set the position to relativeand have your div placed relatively to its normal position.
You can check this for more information on the position property;
You could insert DIV within DIV. And you could position DIV using the top and left style attributes.
<div id="page1" style="{background:url('http://s27.postimg.org/r5v9ymd77/pg3bgl.png');background-size:cover;}">
<span class="">Page 1</span>
<div id="subpanel_1" style="top:20px; left:102px;>
<!-- Content Goes Here -->
</div>
<div id="subpanel_2" style="top:200px; left:50px;>
<!-- Content Goes Here -->
</div>
</div>
Of course, instead of writing the style definitions inline, better put them in a separate <style>…</style> block.
I'm pretty much trying to copy what you see in the following picture. I have three sections. Between section 1 and section 2 (the blue section) you can see the white arrow-box. That's what I can't place properly without messing things up.
Now I already got this "working" by placing the arrow box inside the blue section, and then gave both the arrow-box and the blue section absolute positions, and then gave the arrow box some minus margin from top. The problem with this is, that for some reason I can't create section 3 that is supposed to come after the blue section. I can't place anything under the blue section if its position is absolute. If I give the blue section a relative position, things obviously start working normally again, but then the arrow box gets out of place and something like this happens:
My code looks something like this, HTML:
<section id="first-section">
<!-- bunch of stuff here -->
</section>
<section id="blue-section">
<div class="arrow_box">
<p>How can I help you?</p>
</div>
</section>
<section id="third-section">
<!-- More stuff here -->
</section>
CSS:
#blue-section {
position: relative;
}
.arrow_box {
position: absolute;
width: 500px;
height: 100px;
left:0;
right:0;
margin-left:auto;
margin-right:auto;
margin-top: -50px;
}
OK, then here you go:
HTML
<section class="container" id="first-section">
<!-- bunch of stuff here -->
</section>
<section class="container" id="blue-section">
<div class="arrow_box">
<p>How can I help you?</p>
</div>
<div class="col"> <img src="http://www.andalucesdiario.es/wp-content/uploads/2014/09/tyrion_lannister.jpg" alt="" /> </div>
<div class="col"> <img src="http://www.andalucesdiario.es/wp-content/uploads/2014/09/tyrion_lannister.jpg" alt="" /> </div>
<div class="col"> <img src="http://www.andalucesdiario.es/wp-content/uploads/2014/09/tyrion_lannister.jpg" alt="" /> </div>
</section>
<section class="container" id="third-section">
<!-- More stuff here -->
</section>
CSS:
.container{position:relative; background:#ccc; padding:40px; width:100%; height:auto; min-height:100px; text-align:center;}
#blue-section{background:#06c}
.arrow_box{position:absolute; background:#f9f9f9; position:absolute; top:-50px; left:50%; margin-left:-100px; height:100px; width:200px;}
.col{width:30%; padding:1%; display:inline-block;}
.col img{width:200px; height:200px; border-radius:50%;}
As you can see, you weren't that wrong, you just need to understand that absolute positioning requires a relatively positioned div in order to be positioned itself.
See the possible values so you understand (from Mozilla MDN)
static
This keyword lets the element use the normal behavior, that is it is laid out in its current position in the flow. The top, right, bottom, left and z-index properties do not apply.
relative
This keyword lays out all elements as though the element were not positioned, and then adjust the element's position, without changing layout (and thus leaving a gap for the element where it would have been had it not been positioned). The effect of position:relative on table-*-group, table-row, table-column, table-cell, and table-caption
elements is undefined.
absolute
Do not leave space for the element. Instead, position it at a specified position relative to its closest positioned ancestor or to the containing block. Absolutely positioned boxes can have margins, they do not collapse with any other margins.
fixed
Do not leave space for the element. Instead, position it at a specified position relative to the screen's viewport and doesn't move when scrolled. When printing, position it at that fixed position on every page.
sticky
The box position is calculated according to the normal flow (this is called the position in normal flow). Then the box is offset relative to its flow root and containing block and in all cases, including table elements, does not affect the position of any following boxes. When a box B is stickily positioned, the position of the following box is calculated as though B were not offset. The effect of ‘position: sticky’ on table elements is the same as for ‘position: relative’.
And if you made it here, you get a free fiddle
<body>
<!-- //take it as example, it may help u, just make the arrows boxed div child of blue div ,
//i ll call upper white section as white as give it white as id, arrow boxed as box,blue as blue
-->
<div id="container">
<div id="upper">
<!--//content of this div;-->
</div>
<div id="blue">
<div id="box" style="position:relative; top:-100px; z-index:10000; margin:0 auto; width:40%;">
<!-- // adjust top attr.-->
</div>
<!--//here blue sectiions content is inside lower part.-->
<div id="lower" style="margin-top:200px">
<!--//try as much u want to space to be below thw box;-->
</div>
</div>
</div>
</body>
I have a div on my homepage, not positioned, it holds the main image. On top of this main image I have a container which holds my search bar. I've positioned this container position:relative top:-500px; so that it appears over my main image.
I then have another 2 containers which come next, but if I do nothing positionally with them, they appear after a big vertical space, so I've had to position:relative and add a minus top to. I have to keep doing this top:-300px or whatever because if I don't a space appears beneath which I can't fill.
Now the next div down is the footer which I don't want to have to posiiton because it appears on every page. How can I get rid of the space between my featured properties and the footer?
Here's the code:
//no positioning
<div style="margin: 0 auto" class="slideshowWrap">
<div class="homeslideshow slide1">
</div>
<div class="homeslideshow slide2">
</div>
<div class="homeslideshow slide3">
</div>
</div>
//position:relative top:-500px
<div id="homecontainer">
</div>
//position:relative; top:-300px; margin-bottom:-100px;
<div id="homeBoxContainer">
</div>
<div style="clear:both"></div>
//position:relative; top:-300px;
<div id="homeFeaturedContainer">
</div>
You have a problem the way you designed your containers. When you moved everything up using position:relative and top:-300 it moves everything up, but the height from your #content is still saving the space and maintaining the height.
If you want your footer links up, add the following code
#footer {
top: -300px;
position: relative;
}
that doesn't solve your problem because you still have the big height created by your odd design. You need to go back to the drawing board and redesign your container. You don't need the position:relative and moving everything up.
I generally only set top and bottom values on absolutely-positioned elements. Try this instead:
#homeFeaturedContainer {
margin-top: -300px;
margin-bottom: -300px;
}
I Want to place a div over another div without using height in pixels.I have used this code
<div style="position: relative;height:78px;">
<div style="width:425px;position: absolute;top: 0;left: 0;">
Content for First div
</div>
<div style="z-index:10;position:absolute;top: 0;left: 0;">
Content for Second div
</div>
</div>
The first div content will change dynamically . So is their any way to put height auto some thing like in parent div
both child divs are taken out of the flow, so the parent will have no natural height (which normally is "stretched" by it's children).
since you have pre-loaded data on the first child div, make the second match to it.
HTML:
<div id="parent">
<div id="firstChild">
Content for First div
</div>
<div id="secondChild">
Content for Second div
</div>
</div>
CSS:
#parent{
position:relative;
}
#firstChild{
width:425px;
}
#secondChild{
width:425px;
position:absolute;
top:0;
bottom:0;
}
NOTE: watch out for collisions in your styles, i used ID here. replace accordingly
height: 100% should make it the height of the parent div which is 78px;
I'm working in a web site, but it's the first time that a client ask me for ipad compatibility. So I started to work like usual but at the moment to see the result on the ipad there are some objects that i can't put in the correct position.
I already tried to change all my absolute positioning with margins and paddings, but this part(image above) does not work, when i change the position the content stay in the same place.
The current web site
The current css
But the important part is here:
<div id="super-wrapper">
<div id="wrapper">
<!-- Some Divs -->
<div id="content" class="open">
<!--This menu will be hidden -->
<ul id="navigation-fans">
<li id="registrate"><span>Registrate</span></li>
<li id="crea-club"><span>club</span></li>
<li id="conoce-clubs"><span>clubs</span></li>
</ul>
<div id="close-open" class="open"></div>
<div id="title"></div>
<div id="real-content"></div>
</div>
<!-- Some Divs -->
</div>
</div>
css
#wrapper{
width:1024px;
height:768px;
margin: 10px auto;
position:relative;
background: url(../../pics/1.jpg) no-repeat;
overflow:hidden;
}
#content{
background-image:url('../images/secciones_fondo.png');
height:423px;
width:1024px;
display:block;
position:relative;
right:-374px;
padding-top:1px;
margin-top:143px;
}
/* This is the position of #content when is open */
element.style {
right: -374px;
}
Update
I found that the problem is jplayer, but i still don't know wich is the real problem, by the moment i disable it and it works.
it might be your super-wrapper tag that you are not assigning correct properties to. If you look at the code, super-wrapper is essentially holding the same as wrapper, correct? If so, wrapper could be inheriting properties from super-wrapper which you might not be what you want.
Hope this helps.