Div positioning varies when runat="server" - html

Hai guys,
Error div is placed under menu div when there is no runat="server".... But When i give Runat="server" Error div placed to the right of menu div.. any suggestion for placing error div under menu div
<div id="content">
<div id="menu">
</div>
<div id="ErrorDiv" runat="server">
</div>
</div>
css:
#content
{
clear:both;width:100%;float:left;
}
#menu
{
clear:both;float:left;padding-left:15px;width:70%; height:37px;
}
#ErrorDiv
{
clear:both; width:75%;float:left;
}

When runat="server", the ID of the div changes, so the CSS rule isn't applied (you can see it if you view the source of your page).
A simple solution is to use a css class, or a combination of two elements - one that runs at the server, and one that doesn't.

Related

How do I prevent one DIV from sitting on top of another DIV?

I’m having trouble getting one div not to lie on top of another div. I have the following
<div id="navbar">
<div id="leftNavSection"></div>
<div id="rightNavSection">Logged in as Dave <a rel="nofollow" data-method="delete" href="/logout">Log Out</a></div>
</div>
with the accompanying CSS …
#rightNavSection {
float: right;
}
However, when I add this div underneath, it lines up on the same vertical plane as the nav div.
<div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
</div>
Here is the JSFiddle that illustrates the problem — https://jsfiddle.net/z4rw9qj1/ . If I add a fixed height to the nav div (e.g. “height: 10px;”), then the overlay doesn’t happen, but I don’t want to add a fixed height because if someone adjusts their browser font size, or I add other elements, then the look is broken. Is there a way I can get the lower div not to trample the upper div?
That's because of float: right and you can fix that if you add overflow: hidden on header DEMO
header {
overflow: hidden;
}
Have you tried the z-index property ? It is a property that decides what order are the elements aligned in the "front-back" axis.
http://www.w3schools.com/cssref/pr_pos_z-index.asp

How can I arrange divs of different height on 2 lines, cannot edit HTML

I want to make two lines of divs. The divs are of different height. Like in the image bellow.
These divs are wordpress posts. They should go like this: first on the left, next one on the right, next one on the left etc.
Unfortunately, I can change only the style of the div that will contain the wordpress post. I cannot add html tags or make two columns in the html. So, can it be done only by styling the div element?
The divs don't have IDs,I have to get them with #container div{}
The only solution I found is this one:
div{float:left; width:345px; min-height:680px; max-height:680px;}
This works, but some of my divs are above 680px and they get on top of the others.
Assuming you want every other div pulled aside like this:
div:nth-child(2n+3) {
float:left;
}
div:nth-child(2n+4) {
float:right;
}
The +3 and +4 are assuming there are 3 divs before these you don't want to touch. This would need tweaking for your specific situation, but without seeing specific structure it's impossible to say anything for certain.
Try the following:
<div id="left-side">
<div class="pull-left">
</div>
<div class="pull-left">
</div>
<div class="pull-left">
</div>
</div>
<div id="right-side">
<div class="pull-left">
</div>
<div class="pull-left">
</div>
<div class="pull-left">
</div>
</div>
with the following CSS:
left-side {
float: left;
}
right-side {
float: right;
}
pull-left{
float: left;
}

prevent div from getting pushed to the left

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

Wrapping a containing div with another div

I don't know how to summarize my situation, but here's the simplified code showing the problem (index.html) :
<html>
<body>
<div id="wrapper" class="divide">
<div id="top" class="divide">
....(all of its contents)....
</div>
<div id="content" class="divide">
<div id="left">
....(all the contents)....
</div>
<div id="right">
....(all the contents)....
</div>
</div>
</div>
<div id="footer">
</div>
</body>
</html>
(style.css)
.divide{
margin-left:auto;
margin-right:auto;
width:960px;
}
body {
background-color: #666600;
}
#left {
......
......
float: left;
}
#right {
......
......
float: left;
}
#wrapper{
background-color:#ffffff;
}
So here I want the "wrapper" div background to be white in color, and the body background surrounding it to have another color (in here I put the brownish color). This works for the "top" div, but not the "content" div (thus, all of its children). The "content" div has the same background color as body, which doesn't make sense to me because the "wrapper" div does contain "content" div.
In other word, the "wrapper" div seems doesn't reach the "content" div and all of its children. Is there any workaround for this problem? Inform me if you all need additional information. Thanks for any help!
NOTE: As our helpful people pointed out, the floating properties in the div element does cause the above problem. I did not realize that. That's why I didn't put the floating properties in the first place. So I just edited the above code so that we know what's really causing it. Peace!
Do you have any floated elements, such as #left and #right?
If so, you need to clear your floats.
One way to do that is to add overflow: hidden to #wrapper.
You should also fix a small mistake in your HTML: </left> to </div>.
If you float your content divs, you might be having a problem with not clearing the floats. Try adding overflow:auto to your wrapper div
I put your code into JSFiddle and got this: http://jsfiddle.net/XPLWR/, it looks fine to me.

HTML and CSS button alignment

How can I right align a button inside a div without wiping it from the Markup Flow with valid CSS and HTML? Is applying margin-leftthe only way to do this?
I have a structure like this
<div class="navContainer">
<div class="title">
<span>Nav Titulo</span>
</div>
<div class="navContent">
Nav Conteudo
</div>
<button type="button">Enviar</button>
</div>
<div class="navContainer">
<div class="title">
<span>Nav Titulo</span>
</div>
<div class="navContent">
Nav Conteudo
</div>
</div>
If I apply button { float: right } or button { position: absolute } the next div will get over the button. It happens that I just want to make the button position at the right side
what you want to read up on is clearing
if you have floated elements, they go out of page flow, but any element with clear:both will stay in page flow, but not allow anything on either side of it, floated or not.
in practice, adding a clear:both element after you floats makes things work the way you want them to.
.navContainer { text-align: right; }
#Matt is right. What you need to do is clear the div elements.
.navContainer {clear: both}
If you want your button aligned at the top of the containing div, you might have to move it before your div element of class "title".