I've got a dialog box made of a series of divs for the header, body and footer which are further subdivided into left, center and right sections each. Picture a tic tac toe board and you'll get the idea. For some reason, as soon as I put a textarea in the body center it overlaps the left and right body divs. The problem is occurring somewhere in the div section that uses the "con" classes.
Here's a picture of the problem: http://s8.postimage.org/fvlt9qi51/Dialog_Overlap.jpg
Edit: I managed to make it work by replacing height: 100% with height: 175px in the .con section of CSS. What I don't understand is why that looks ok, but height: 100% doesn't? The top level div that contains all the sub divs that make up the dialog has it's dimensions specified in pixels, as does the dialog header and footer. Why does the middle have to have an exact value specified as well? I'd rather not do it this way as it means I'll need a special CSS class for each dialog box so that a specific height value can be added to the middle of the dialog.
The HTML is below, CSS is after that.
<div class="ttl">
<div class="ttlt">
<div class="ttlt-l"></div>
<div class="ttlt-m">
<a class="close" href="javascript:void(0);" onclick="cancelNotes();this.blur();return false;"></a>
<span>Create Note</span>
</div>
<div class="ttlt-r"></div>
</div>
<div class="ttlb">
<div class="ttlb-l"><span></span></div>
<div class="ttlb-m"><span></span></div>
<div class="ttlb-r"><span></span></div>
</div>
</div>
<div class="con">
<div class="con-l"></div>
<div class="">
<input type="hidden" id="hdnNoteID" />
<textarea id="txtNote" rows="11" cols="50"></textarea>
</div>
<div class="con-r"></div>
</div>
<div class="ftr">
<div class="ftr-l"></div>
<div class="ftr-m">
<a onclick="cancelNotes();this.blur();return false;" href="javascript:void(0);" class="btn"><span>Cancel</span></a>
<a onclick="addNotes();this.blur();return false;" href="javascript:void(0);" class="btn"><span>Add Note</span></a>
</div>
<div class="ftr-r"></div>
</div>
CSS
/* Title Bar */
.ttl { width:100%;height:38px; }
/* Close button */
.ttl a { margin-top:4px;display:block;float:right;width:23px;height:21px;background:transparent url("img/dialog/static.png") no-repeat -18px 0;cursor:default; }
.ttl a:hover { background-position:-18px -21px; }
.ttl a:active { background-position:-18px -42px;outline:none; }
.ttlt { width:100%;height:30px; }
.ttlt-l { width:9px;height:30px;background:transparent url("img/dialog/static.png") no-repeat;float:left; }
/* ttlt-m width is dialogue width (450px) - 18px (the left & right divs are 9px each) */
.ttlt-m { width:432px;height:30px;background:#000 url("img/dialog/horizontal.png") repeat-x;float:left; }
.ttlt-mWide { width:632px;height:30px;background:#000 url("img/dialog/horizontal.png") repeat-x;float:left; }
.ttlt-mExtraWide { width:930px;height:30px;background:#000 url("img/dialog/horizontal.png") repeat-x;float:left; }
.ttlt-r { width:9px;height:30px;background:transparent url("img/dialog/static.png") no-repeat -9px 0;float:left; }
.ttlt span { cursor:inherit;margin-left:4px;line-height:30px;color:#fff;font-weight:bold;font-family:Tahoma,"Lucida Grande",Verdana,Arial,Helvetica,sans-serif;font-size:11px; }
.ttlb { width:100%;height:8px; }
.ttlb span { display:none; }
.ttlb-l { width:9px;height:8px;background:#000 url("img/dialog/static.png") no-repeat 0 -30px;float:left; }
/* ttlb-m width is dialogue width (450px) - 18px (the left & right divs are 9px each) */
.ttlb-m { width:432px;height:8px;background:#fff url("img/dialog/horizontal.png") repeat-x 0 -67px;float:left; }
.ttlb-mWide { width:632px;height:8px;background:#fff url("img/dialog/horizontal.png") repeat-x 0 -67px;float:left; }
.ttlb-mExtraWide { width:930px;height:8px;background:#fff url("img/dialog/horizontal.png") repeat-x 0 -67px;float:left; }
.ttlb-r { width:9px;height:8px;background:#000 url("img/dialog/static.png") no-repeat -9px -30px;float:left; }
.tabbed .ttlb-l { background-position:0 -38px; }
.tabbed .ttlb-m { background-position:0 -75px; }
.tabbed .ttlb-r { background-position:-9px -38px; }
/* Body */
.con { width:100%;height:100%;background-color:#fff;font-family:Tahoma,"Lucida Grande",Verdana,Arial,Helvetica,sans-serif;font-size:11px; cle}
.con-l { width:9px;height:100%;background:#000 url("img/dialog/vertical.png") repeat-y;float:left; }
/* con-m width is dialogue width (450px) - 18px (the left & right divs are 9px each) */
.con-m { width:432px;height:100%;background-color:#fff;float:left; }
.con-m .top { margin-top:2px; }
.con-mWide { width:632px;height:100%;background-color:#fff;float:left; }
.con-mExtraWide { width:930px;height:100%;background-color:#fff;float:left; }
.con-r { width:9px;height:100%;background:#000 url("img/dialog/vertical.png") repeat-y -9px 0;float:left; }
/* Dialogue footer */
.ftr { width:100%;height:37px;font-family:Tahoma,"Lucida Grande",Verdana,Arial,Helvetica,sans-serif;font-size:11px; clear: left;}
.ftr-l { width:9px;height:37px;background:transparent url("img/dialog/static.png") no-repeat 0 -75px;float:left; }
/* ftr-m width is dialogue width (450px) - 18px (the left & right divs are 9px each) */
.ftr-m { width:432px;height:37px;background:#eee url("img/dialog/horizontal.png") repeat-x 0 -30px;float:left; }
.ftr-mWide { width:632px;height:37px;background:#eee url("img/dialog/horizontal.png") repeat-x 0 -30px;float:left; }
.ftr-mExtraWide { width:930px;height:37px;background:#eee url("img/dialog/horizontal.png") repeat-x 0 -30px;float:left; }
.ftr-r { width:9px;height:37px;background:transparent url("img/dialog/static.png") no-repeat -9px -75px;float:left; }
It is hard to help there without access to real thing.
Block .con and its left and right parts have height:100%. This will work only if they parent have height in pixels. Now this left and right parts invisible, because they have height 0. It will be simpler to help if you will provide html and css for outer div for this blocks. Try to set fixed height for it like 300px.
Also I can suggest dirty workaround. Add this css after your styles:
.con {
border:9px solid #000;
border-width:0 9px;
padding:0 9px;
width:auto;
}
Related
I am trying to create the following design
Where the left side is an image followed by a tag with words.
on the right are the menu options which should look like they are clickable. The slashes that separate them should never move change color etc. However "About" "Contact" and "The Future" will eventually look different when hovered over and will take you to different pages on the site.
So when I attempted to create this I made the following HTML and CSS (make sure the window is wide when you run it)
.modernShadow {
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
}
.fittingObject {
max-width: 100%;
max-height: 100%;
}
#topdiv {
position: fixed;
z-index: 2;
background-color: #4FBEA9;
width: 100%;
height: 44pt;
padding-top: 3pt;
padding-bottom: 3pt;
padding-left: 3pt;
padding-right: 3pt;
}
#topdiv * {
display: inline;
vertical-align: middle;
}
.title {}
.titleLogo {}
.titleHere {
color: white;
}
.rightList {
float:right;
vertical-align: middle;
}
<header>
<!-- Displays in tab bar -->
<title>Logo Here</title>
<div id="topdiv" class="modernShadow">
<img src="https://cdn1.iconfinder.com/data/icons/computer-system-files-essential-glyph/48/Sed-40-512.png" class="fittingObject" />
<h1 class="title">
<h1 class="titleLogo">Logo</h1>
<h1 class="titleHere">Here</h1>
</h1>
<nav class="rightList">
<ul>About</ul>
/
<ul>Contact</ul>
/
<ul>The Future</ul>
</nav>
</div>
</header>
And the result is this
And I can't explain why because I don't understand what is happening to make it this way.
Why are components under float:right not vertically aligned like everything else? I believe #topdiv * gives every subcomponent the style vertical-align: center so why isn't that coming into play?
Where is the spacing between the words and the "/"s coming from?
I am not sure it isn't just a fluke that "Logo Here" is appearing vertically centered... Maybe that is just the font size? But that is set by the .fittingObject css. (the title logo should be as big as it can be)
The end goal is essentially the picture above. The font size of the right items is variable and the text should just always be vertically centered inside of the containing div.
Answers:
Float doesn't work with vertical align, read more about it here; CSS Vertical align does not work with float
UL's have the property padding-inline-start which has a default of 40px and is pushing content to the right.
Max width and Max height properties only specify the limit of a certain element, it doesn't indicate their actual width and height values.
I modified your html to include wrapper divs; classes with left and right. In the right div I placed your rightList which has line-height css property and is an alternative to vertical-align:middle.
.modernShadow {
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
}
.fittingObject {
max-width: 100%;
max-height: 100%;
}
#topdiv {
position: fixed;
z-index: 2;
background-color: #4FBEA9;
width: 100%;
height: 44pt;
padding-top: 3pt;
padding-bottom: 3pt;
padding-left: 3pt;
padding-right: 3pt;
}
#topdiv * {
display: inline;
vertical-align: middle;
}
.title {}
.titleLogo {}
.titleHere {
color: white;
}
.left,
.right {
width: 49%;
display: inline-block;
}
.rightList {
width:230px;
float: right;
line-height: 60px;
}
.rightList ul {
padding-inline-start: 0px;
}
<header>
<!-- Displays in tab bar -->
<title>Logo Here</title>
<div id="topdiv" class="modernShadow">
<div class="left">
<img src="https://cdn1.iconfinder.com/data/icons/computer-system-files-essential-glyph/48/Sed-40-512.png" class="fittingObject" />
<h1 class="title">
<h1 class="titleLogo">Logo</h1>
<h1 class="titleHere">Here</h1>
</h1>
</div>
<div class="right">
<nav class="rightList">
<ul>About</ul>
/
<ul>Contact</ul>
/
<ul>The Future</ul>
</nav>
</div>
</div>
</header>
do you have any particular reason to use <ul> for all the navs?
if you use
<ul>
<li>About</li> /
<li>Contact</li> /
<li>The Future</li>
</ul>
it will generate the display as you wanted.
the <ul> has default user agent stylesheet.
and for the vertically centered text, if you already set the height for the blocks, you can always use the same statement for line-height (in this case is 44pt) to make it vertically centered.
I have 4 images in a css vertical sprite that I want each become a href's on my page going horizontal. Starting at left:250px top:2px and with padding of 3px between each image.
CSS
.sprites {
background:url('/pic/sprites.jpg')no-repeat top left;
width:36px;
height:36px;
}
.sprites.sprites.twitter {
background-position:0px 0px;
}
.sprites.sprites.facebook {
background-position:0px -46px;
}
.sprites.sprites.google-plus {
background-position:0px -92px;
}
.sprites.sprites.pinterest {
background-position:0px -138px;
}
.social {position:relative;left:250px;top:2px;}
I can figure out how to start in 250px from the left and 2px from the top, but I can not figure out how to get the images going horizontally as a href's with padding of 3px
html
<div class=social>
<div class='sprites google-plus'></div>
<div class='sprites facebook'></div>
<div class='sprites twitter'></div>
<div class='sprites pinterest'></div></div>
You need to add display: inline-block/block; depending on what you want to achieve, this should work for you
Problem: The idea is the div that changes the colour of its contents on hover. Except the text and image (sprite) colours change at different points; the text on hover above the 'address' div and the image above the 'addressicon' div. Does anyone know how I could I get both to change on hover over the the 'address' div.
HTML:
<section id="gallery">
<div class="container" style="padding-top:40px;">
<div class="address"><div class="title"><span>Address</span></div><br>
<div class="addressicon"></div>
<p><br>Address1<br>
Address2<br>
Address3<br>
Area<br>
City<br>
PostCode
</p>
</div>
<div style="width:33%;height:400px;display:inline-block;background-color:#000000"></div>
<div style="width:33%;height:400px;display:inline-block;background-color:#000000"></div>
</div>
</section>
CSS:
.address {
width:33%;
height:400px;
display:inline-block;
background-color:#CCC;
color:#bcb7af;}
.address:hover {color:#000000;}
.address span {
color:#bcb7af;
align:center;
font-size:24px;
width:100%;}
.address:hover span {
color:#000000;}
.title {text-align:center;}
.addressicon {
background: url(../images/address.png) bottom;
width:202px;
height:130px;
margin: 0px auto;}
.addressicon:hover {
background-position: 0 0;}
Many thanks
Problem Solved New CSS:
.address > .addressicon {
background: url(../images/address.png) bottom;}
.address:hover > .addressicon, {
background-position: 0 0;}
.address:hover > .addressicon {
color: SOMETHING;
}
And never leave a div empty. Put an in it, to prevent it from stupid behaviors.
I have web page
www.turie.eu
There are some facebook comments at the bottom. What do I have to change to dynamically change the height and display all 16 comments?
I have tried to change height of every single css selector that have something to do with the comments part from single value to 100% or auto, but with no effect.
Thank you!
This is because:
#contenwrap {overflow: hidden}
When you remove this rule, you´ll get some other design issues to solve, but you are on the right path :-)
Update!
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #FFF url(pozadie04.jpg) no-repeat scroll center top;
margin: 0;
padding: 0;
color: #000;
}
/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
padding-right: 15px;
padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
}
/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
color: #42413C;
text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
color: #6E6C64;
text-decoration: underline;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
}
/* ~~ this fixed width container surrounds all other elements ~~ */
.container {
width: 960px;
margin: 280px auto 0; /* the auto value on the sides, coupled with the width, centers the layout */
box-shadow: 0 0 40px black; /* Not supported in IE7 and IE8 */
}
.header {
width:960px;
height:280px;
position:absolute;
top:0;
}
.headerPic {position:absolute;}
.Logo {bottom: 35px; left:98px}
.Church {bottom: 0; right:70px}
/* ~~ This is the layout information. ~~
1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
*/
.content {
padding: 10px 0;
background:rgba(255,255,255,0.9); /* Not supported in IE7 and IE8 */
border:1px solid #fff;
}
.forum {
height:130px;
}
.maps {
height:523px;
}
.fb {
width:600px;
background: #FFF url(facebookcomments_nadpis.png) no-repeat left top;
padding-top: 70px;
margin-left:15px;
}
.mb {
width:300px;
background: url(mikroblog-nadpis.png) no-repeat left top;
padding-top: 70px;
margin-right:15px;
}
.footer {
width:960px;
height:237px;
background: url(footer.png) no-repeat bottom;
}
/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the overflow:hidden on the .container is removed */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style></head>
<body>
<div class="container">
<div class="header">
<img class="headerPic Logo" src="maco07.png" width="277" height="185" alt="Logo">
<img class="headerPic Church" src="kostol03.png" width="170" height="230" alt="church">
<!-- end .header --></div>
<div class="content">
<div class="forum">
<p>Place your forum in this DIV</p>
<!-- end .forum --></div>
<div class="maps">
<p>Place your Google Map in this DIV</p>
<!-- end .maps --></div>
<div class="hero">
<h1>Vitajte!</h1>
<p>Turie.eu je komunitný web s cieľom prezentovať obec Turie formou interaktívnych panoramatických fotografií. Vzhľadom na všeobecne nízku úroveň interaktivity na stránkach obcí, bude možnosť spoluvytvárať obsah Turie.eu jej návštevníkmi našou prioritou.</p>
<p>Stránka funguje vo všetkých moderných prehliadačoch a v IE8+. Ak nájdete nejaké chyby, máte návrhy na zlepšenie, alebo sa chcete podieľať na vytváraní obsahu, napíšte nám.</p>
<p>Chystané zmeny: užívateľská fotogaléria, kalendár udalostí, filtrovanie markerov, hlasovania, rezervácie..</p>
<!-- end .hero --></div>
<div class="wrap">
<div class="fb fltlft">
<h2>Facebook </h2>
<p>sdlkfjsdf kjsadf slkødfj sødlfkj sadlkfj sad flkj</p>
<p>sdlkfjslkdjflksjdflkjsdf</p>
<p>sdflkjsdlfkjsdlkfj</p>
<p>sldkfjlkdsfj</p>
<p>Float is cleared in this DIV</p>
<!-- end .fb --></div>
<div class="mb fltrt">
<h2>Mikroblog</h2>
<p>sdkfljøslkdfjlkjdsfølkj</p>
<p>sdlkfjølskdjfølksjdf</p>
<p>sdlkfjøsldkfjølskdfj</p>
<p>sdlfkjøsldkfj</p>
<p>sdlkfjøsldkfj</p>
<p>sdflkjsdøflkj</p>
<p>slskdjfølksdjf</p>
<p>Float is cleared in this DIV</p>
<!-- end .mb --></div>
<br class="clearfloat">
<!-- end .wrapper --></div>
<!-- end .content --></div>
<div class="footer">
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
</html>
you can use scrolling div, Use css overflow property or overflow:auto for scroll
Here is the IE fix for rgba issue. I used Kimili´s generator on his site (great tool).
<!--[if IE]>
<style type="text/css">
{
background: transparent;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#E5FFFFFF,endColorstr=#E5FFFFFF)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#E5FFFFFF,endColorstr=#E5FFFFFF); /* IE6 & 7 */
zoom: 1;
}
</style>
<![endif]-->
The code:
HTML:
<div id = "LeftDiv">
<p class = "hdr">ADVANCED SEARCH:</p>
<div class = "LeftItem">
<form>
<p style="margin:0;padding: 10px 0;">Weird Space above this</p>
<input type = "text" name = "search" />
<input type = "submit" value = "Go" />
</form>
<br />
</div>
<br />
...There are some more (like a vertical navigation bar,
which also has this gap between the header and the navigation bar)
CSS:
#LeftDiv
{
float: left;
width: 20%;
text-align: center;
color: #fff;
}
.LeftItem
{
background: #000 url("") no-repeat;
}
.hdr
{
text-transform: uppercase;
font-weight: bold;
background: url("header.png") no-repeat;
padding: 10px 0;
margin: 0;
}
The weird thing is, this happens in Firefox, but not in Chrome. Also, this space disappears when I zoom when using Firefox.
I'm not really sure why this happened. Is this because the <p> is not inside the 'LeftItem' div?
try adding no margin/padding for every element:
*
{
padding:0;
margin:0;
}
EDIT REGARDING YOUR COMMENTS:
You don't want to use padding to fit your image in. What you do is get your image width and height, and do this:
.hdr
{
width:100px;
height:100px;
display:block;
background:url("header.png") no-repeat;
}
.hdr span
{
font-weight:bold;
text-transform: uppercase;
padding: 6px auto;
}
(instead of 100px, use actual size, and 6px is a wide guess)
ANd then use html:
<div class="hdr"><span>advanced search</span></div>