CSS Spacing Issue - css

I have a large graphic that I am trying to pull up behind my content. Currently, instead of pulling up behind my content, the graphic is just placed below it, which leaves a big gap between the bottom of the content and the footer. The large graphic in reference is the watercolor bird at the bottom. The content is the resume text. Keep in mind that that resume text is an accordion link that expands. I need help closing up this space, please.
http://imip.rvadv.com/index3.html
CSS:
#bottom-graphic-container {
margin:0;
padding:0;
background:#fff url(../images/bg-bottom.jpg) bottom left no-repeat;
height:313px;
}
.wrapper{
max-width:920px;
margin:25px auto 0 auto;
padding:0;
width:100%;
z-index:1;
}
.st-accordion ul li.st-open > a{
/*margin-top:70px;*/
}
.st-open:last-child .st-content {
padding-bottom: 0;
}
.st-content{
padding: 5px 0px 100px 0px;
}
.st-content p {
font-size: 14px;
font-family: Georgia, serif;
font-style: normal;
line-height:22px;
padding: 0px 4px 15px 4px;
}
.st-accordion{
width:100%;
min-width:270px;
margin:0 auto;
}
.st-accordion ul li{
overflow: hidden;
padding:0 30px;
}
.st-accordion ul li:first-child{
overflow:visible;
list-style-type:none;
}
.st-accordion ul li:last-child{
}
.st-accordion ul li > a{
font-family: 'Trocchi', serif;
text-shadow: 1px 1px 1px #fff;
color:#688993;
line-height:44px;
font-size: 36px;
display: block;
text-decoration:none;
-webkit-transition: color 0.2s ease-in-out;
-moz-transition: color 0.2s ease-in-out;
-o-transition: color 0.2s ease-in-out;
-ms-transition: color 0.2s ease-in-out;
transition: color 0.2s ease-in-out;
}
.st-accordion ul li > a:hover{
color:#18232e;
}
HTML:
<div class="wrapper">
<!-- <div class="chirp">chirp</div>-->
<div id="st-accordion" class="st-accordion">
<ul>
<li>
Chirp. Would you like to know about me?<h2>Read the official birdwatcher's guide.</h2>
<div class="st-content"><p>content goes here</p>
</div>
</li>
<li>
A bird's eye view of my endeavors<h2>and other flights of fancy, also known as my portfolio.</h2>
<div class="st-content">
<p>Portfolio Goes Here.</p>
</div>
</li>
<li>
My migration pattern<h2> and other common facts, otherwise known as my resume.</h2>
<div class="st-content"><p>content goes here</p>
</ul>
</div>
</div>
</div>
<!--bottom graphics-->
<div id="bottom-graphic-container"></div>
<!--Footer-->
<div id="footer-container">
<div id="footer-content-container">
<div id="footer-copy">Tiffani Hollis, Creative Professional (404)931.6057 thollis#i-make-it-pretty.com</div>
<div id="signature"><img src="images/signature.png"></div>
</div>
</div>

I replicated your website locally and was able to fix this for you.
Reference: jsFiddle 1 (Note: Due to #font-face Same Domain Orgin Rules, those font's aren't shown.)
The solution was to change the HTML order for the Corner Bird so that this Div with ID name #bottom-graphic-container will contain the Accordion content (with class name .wrapper ).
Then, several modifications/configurations were done to the CSS to allow for proper operation. Notably, I set the Footer and the Corner Bird Div's to position:fixed; so it always clings to the bottom. When there's Link's or Resume Text behind the Footer, the expected browser scrollbar comes into play.
To clarify further: The Corner Bird is the "back-layer", the Accordion is the "middle-layer", and the Footer is the "front-layer". They all work in harmony now. :-D
Since the Corner Bird is now behind the Accordion div, that bg-background.jpg was clipping into the Header Image. The solution was to convert this image to PNG with Transparency. I used open source irfanview for that. I've included that PNG here as well, or you can make your own.
When all is said and done, your website will work as you expect it to. Tested in IE8, Firefox, and Chrome with no issues. (Side note: In IE8 I did not test #font-face fonts).
Here's a screenshot of your webpage with the browsers window adjusted to a small size:
The modified HTML:
<!--bottom graphics--><!-- Think of this as "bottom-back-layer" since various layers are at play here. -->
<div id="bottom-graphic-container">
<!--Footer-->
<div id="footer-container"><!-- Think of this as "bottom-front-layer". That said, back-layer and front-layer are also 'top' and 'bottom' too (nothing overlaps). -->
<div id="footer-content-container">
<div id="footer-copy">
<!-- Removed personal info -->
</div>
<div id="signature"><img src="images/signature.png"></div>
</div>
</div>
</div> <!--Closing tag for bottom graphics-->
The modified CSS:
.wrapper{
width: 920px;
max-width:920px;
margin: 0 auto;
padding: 0;
margin-bottom: 65px; /* Once the last item in Accordion menu is behind Footer, margin-bottom:65px; will provide Browser main scrollbar if hidden. */
position: relative; /* position:relative required with z-index below. (or absolute can be used with more CSS settings */
z-index: 1; /* A z-index of 1 is used since it's higher than '#bottom-graphic-container' (0 z-index) so Accordion Links are clickable */
}
#bottom-graphic-container {
width:100%;
height:313px;
background-image:url(../images/bg-bottomTrans.png); /* Use transparent PNG image. This CSS rule has color #fff removed as well. */
background-repeat: no-repeat;
position: fixed;
bottom: 94px; /* The height used here is the height of 'bg-footer.png' image. */
/* border: 1px solid red; */ /* Use for troubleshooting since image, even when transparent, may prevent interaction with content under it. */
}
#footer-container {
width:100%;
height:94px;
background-image:url(../images/bg-footer.png);
background-repeat: repeat-x;
position: fixed;
bottom:0;
z-index: 10; /* A z-index of 10 will allow the footer to cover the Accordion Links. */
}
#resume-container ul li{
list-style-type:disc;
list-style-position:inside;
line-height:20px;
font-size: 14px;
font-family: Arial, Helvetica, sans-serif;
font-style: normal;
padding-left:20px;
margin-right:80px;
} /* this closing '}' was missing */
The modified PNG with transparency background image file:
bg-bottomTrans.png
Final Update: As the above jsFiddle is one method to satisfy this Question, here is a complete different method at the request of the OP.
Reference: jsFiddle 2
The Bottom Graphic and Footer are part of the last Accordion item (Resume). Note moving up items that were at the bottom to be closer to top will create empty space at bottom of webpage for large monitors (To be sure, maximize your browser). To change the distance, adjust the CSS bottom property for the Bottom Graphic and Footer as noted in the CSS.
This is why the first method above has them fixed so no matter the browser height, uniform look is achieved. Note: Font-face has Same Domain Origin Policy rules, hence they don't render in jsFiddle.
To access the jsFiddle Edit Page, remove /show/ from Address Bar.
The HTML and CSS Panels is your code.
I've included comments in the CSS section and the HTML section changes include:
1. Div id="masthead-container" now contains the other items.
2. The other items are: class="wrapper", id="bottom-graphic-container" and id="footer-container
3. When viewing the HTML in the jsFiddle, the RED tags seen are due to previous markup errors. Once your webpage is composed, visit W3C Online Validation to see where the error occurs. Example: you have an unclosed or extra div tag that shouldn't be there.

I see two possible modification to improve the visual/remove the space:
Change the wrapper class to remove the bottom margin:
.wrapper {
margin: 25px auto -50px;
max-width: 920px;
padding: 0;
width: 100%;
z-index: 1;
}
The line that's changed is the margin one. I put -50px at the bottom margin. You can play with that value (make it lower or higher) to change the space between your wrapper and the footer.
You might want to add a rule to the last accordion child as well. Because he doesn't need the extra bottom padding that separate him from its siblings.
.st-open:last-child .st-content {
padding-bottom: 0;
}
This one target the .st-content div that have .st-open as parent , but only if the block with the .st-parent is the last-child of its parent. Hence, it works only for the bottom part of your accordion, setting a bottom padding of 0 instead of 100px.

Related

Why does the margin of a <p> effect the positioning of the containing div?

I've just come across a CSS issue that I've resolved, but I'd like to know why it happened in the first place or if it is an example of some common CSS behaviour or 'gotcha' I should know about.
Basically, if I did not set the margin of a <p> tag to 0px, I needed to compensate by adding a negative top margin to the containing div (or else there was a 20px space at the top of the div). I found it odd that the margin of the <p> seemed to extend beyond its container.
http://jsfiddle.net/rwone/4znhV/
HTML
<div class="container">
<div class="tab"></div>
<div class="bobble"></div>
<div class="bg">
<p>here is a paragraph la la la la la ...</p>
</div>
</div>
CSS
.container {
margin-top:50px;
}
.tab {
width:39px;
height:12px;
background: #ffe4c0;
border-radius: 3px 3px 0 0;
margin-left:14px
}
.bobble {
background:#fffc68;
height:22px;
width:22px;
float:right;
border-radius:12px;
border: 1px solid #f4f1e4;
margin-top:-8px;
margin-right:-4px;
}
.bg {
background: #F5F3EA;
min-height: 93px;
border-radius: 3px;
width: 100%;
/* margin-top: -20px; this is required if "margin:0px" is not set on <p> */
}
p {
color: #909090;
padding: 20px;
font-size: 20px;
margin: 0px; /* why is this required? */
}
This is due to what is called collapsing margins. According to the Box Model Spec...
Two margins are adjoining if and only if:
both belong to in-flow block-level boxes that participate in the same block formatting context
no line boxes, no clearance, no padding and no border separate them (Note that certain zero-height line boxes (see 9.4.2) are ignored for
this purpose.)
both belong to vertically-adjacent box edges, i.e. form one of the following pairs:
top margin of a box and top margin of its first in-flow child
bottom margin of box and top margin of its next in-flow following sibling
bottom margin of a last in-flow child and bottom margin of its parent if the parent has 'auto' computed height
top and bottom margins of a box that does not establish a new block formatting context and that has zero computed 'min-height', zero
or 'auto' computed 'height', and no in-flow children
If i understood well you want paragraph to expand the container right? This can be done by adding
position:absolute;
to the parent div of and:
position:relative;
to paragraph.
http://jsfiddle.net/7jG75/
Hope i helped.
css inheritance
margin for paragraph was not set so it was inherited from parent container
http://www.webdesignfromscratch.com/html-css/css-inheritance-cascade/
Like this
working fiddle
css
.container {
margin-top:50px;
}
.tab {
width:39px;
height:12px;
background: #ffe4c0;
border-radius: 3px 3px 0 0;
margin-left:14px
}
.bobble {
background:#fffc68;
height:22px;
width:22px;
float:right;
border-radius:12px;
border: 1px solid #f4f1e4;
margin-top:-8px;
margin-right:-4px;
}
.bg {
background: #F5F3EA;
border-radius: 3px;
width: 100%;
position:relative;
/* margin-top: -20px; this is required if "margin:0px" is not set on <p> */
}
p {
color: #909090;
padding: 20px;
font-size: 20px;
margin: 0px; /* why is this required? */
}
Because the browser has default style! if you don't reset the default css, they will act differently! for example p will have 20px margin-top and margin-bottom in chrome while 15px margin-top margin-bottom in ie!
usually if you want want different version and platform browser looks the same, you may have a reset css to remove all the different acts in the browser!
if you want compatible with IE8 and IE8-bellow, you may want this css http://meyerweb.com/eric/tools/css/reset/,other wise you just need a normalize css to make a small hack!
http://necolas.github.io/normalize.css/

Understanding css height and margin

I am new to css and need your guidance. I have a an image background and 2 test lines needs to be placed in that.The top distance between text and image top border should be 50 px. Below to this text there is another text. The distance between these 2 text is 10px. And the distance between the second text(lower text) and the lower end of the image should be 40 px.
I have come up with the below code. Do I need to hardcode height for the first class to be 100px? If I do that the two text becomes too congested. Please let me know if the below code is correct
HMTL
<div class="header1">
<div class="header2" >
The first text goes here
</div>
<div class ="header3">
The second small tesxt goes here
</div>
</div>
CSS
.header1{
display: block;
background-image: url("1.jpg");
background-repeat:no-repeat;
}
.header2{
font-family: Arial;
font-size:42px;
color:#FFFFFF;
height:50px;
margin-top:50px;
margin-left: 170px;
margin-bottom:10px;
}
.header3{
font-family: Arial;
font-size:16px;
color:#FFFFFF;
height:40px;
margin-left: 170px;
margin-top:10px;
margin-bottom:40px;
}
There shouldn't be any need to hardcode heights, or indeed use any heights here, if the content is more important than having the header exactly 100px tall.
Take a look at this fiddle, which uses the CSS below. I think this meets your requirements: http://jsfiddle.net/2LetS/4/
body { color: #ffffff; font-family: Arial; font-size: 16px; }
.header1 {
background: #ff0000; /* Replace this with your image. */
padding: 50px 0 40px 170px;
}
.header2 {
margin: 0 0 10px 0;
font-size: 42px;
}
50px between top of header and first text
10px between first and second text
40px between second text and bottom of header
Note in the example I'm using padding on the .header1 element to define the space around the text, and margins to separate the text elements themselves. You'll also notice there's a lot less CSS code to achieve the same thing.
For your personal development, I think getting an idea of the box model, and what effects margin, padding, widths and heights have on block and inline elements will improve your knowledge immensely for the future.
Hope that helps!
You code is good, you juste need to add this line :
.header1 {
overflow: hidden;
}
Note : .header3 { margin-top:10px; } isn't required, you already fixed this margin on .header2
JsFiddle
According to standards.... For Headings & Sub Headings use H1, H2, H3 Heading tags & define separate styles in css
<div class="header1">
<h1 class="header2" >
The first text goes here
</h1>
<h3 class ="header3">
The second small text goes here
</h3>
</div>
There is no need to define div with class header1 as block as div is already a block level element.
Use % and em as unit of measurements for responsive design.
Always use fallback fonts for font-family property
Try to use shorthand notation for padding, margin, background, border etc.
padding: top right bottom right;
margin: top right bottom right;
background: image_url color repeat-yes/no position;

Overflow is shown mid css3 transition, how can I hide the overflow?

I have the following structure:
<div class="service lorange">
<div class="img"></div>
<div class="title two-lines"><span>P-Accelerator for Start-Ups</span></div>
</div>
And the following CSS:
.service .img {
transition: opacity 300ms;
}
.service:hover .img {
opacity:0
}
.service has a rounded border (35px) and overflow: hidden;.
This causes the inner .title to have its borders cut-off with its parent's borders (this is the expected behavior).
However, during the transition when hovering, and only mid-transition (since it starts and till it ends, not before or after it starts and finishes), the .title borders do not cut off for some reason.
Any idea what's going on?
I've tried making a fiddle, but it doesn't reproduce the issue. What property can be causing this?
Edit: The fiddle in its shell does not reproduce the problem, but looking at the shell alone as a page does (I took the source of the iframe the fiddle uses)
My solution: (But I am looking for a better one.)
#services-grid .service .title {
position: relative;
z-index: 10;
top: 130px;
font-size: 13pt;
text-align: center;
height: 54px; /* IE fix */
/* Add radius to bottom of .title */
border-bottom-left-radius: 8px 15px;
border-bottom-right-radius: 8px 15px;
}
JSFiddle: http://jsfiddle.net/KC4TH/4/
The real reason this is happening is that browsers are only cropping the child element properly if it is not positioned (i.e. has position:static;). I've taken the liberty to alter your markup a bit and created a new jsFiddle which works as it should on Chrome, Firefox and IE10 (also working on IE9 but without the transition ofcourse).
Markup:
<div class="serviceContainer"> <!-- added a container -->
<div class="service lorange">
<!-- removed div.img -->
<div class="title two-lines"><span>P-Accelerator for Start-Ups</span></div>
</div>
</div>
CSS: (I've tried to include only the relevant CSS in the fiddle)
#services-grid .serviceContainer{ /* added a new container which the has the background image */
background:url(http://foto.hrsstatic.com/fotos/0/3/256/256/80/FFFFFF/http%3A%2F%2Ffoto-origin.hrsstatic.com%2Ffoto%2F3%2F9%2F4%2F0%2F394033%2F394033_p_465430.jpg/zoKRL9Oq7JFnhFhhAn%2FfTQ%3D%3D/128,128/6/Catalonia_Yucatan_Beach-Quintana_Roo-Pool-394033.jpg) center center no-repeat;
float:left;
border-radius:35px;
-moz-border-radius:35px;
-webkit-border-radius:35px;
-ms-border-radius:35px;
margin:0 15px;
overflow:hidden;
}
#services-grid .service.lorange .title span{ /* Give background color only to the span */
background-color:#efbd00;
}
#services-grid .service.lorange:hover{ /* fade color to container only when hovered */
background:#efbd00;
}
#services-grid .service .title {
position:static; /* This is what's doing the trick */
padding-top:130px; /* position the span using padding instead of position:absolute */
font-size:13pt;
text-align:center;
}
The "border-radius on the child" solution is only a cosmetic quickfix which can cause inconsistencies and it's also causing little bumps on each side because of the radius difference:

Image coloured hover over overflowing

Just a simple image that uses some jQuery to fade some content over the top when moused over.
Only problem is that when the hover over takes effect, the hover spills into the div gutter making the hover over bigger than the actual container.
each image is layed out like so
<li class="large-4 columns item">
<div class="description"><h1>Image hover</h1></div>
<img class="display" src="http://placehold.it/400x300">
</li>
Can see a live example here.
http://jsfiddle.net/QLUMH/
Any ideas on ways to fix/improve what I am doing here? Cheers
Demo
Here you have live example,
you are giving 100% to width and height.
so that really goes overflow.
Code edited-
#portfolio .description {
position: absolute;
background: rgba(0,199,134,0.8);
display: none;
width: 400px;
height: 300px;
}
The issue is that your description fills the entire column, which is wider than your image. If you add an "inner column"/container that collapse to the same width as your image, it will work alright. I've created a fork of your demo that demonstrates this.
I've added a wrapper "ib" (Just stands for inner block. rename this to a proper name) inside each .column.item like so:
<div class="ib">
<div class="description">
<h1>Image hover</h1>
</div>
<img class="display" src="http://placehold.it/400x300">
</div>
And then just created a very simple CSS rule for making this wrapper collapse to its contents:
.ib {
display: inline-block;
position: relative;
}
You did not style your li. The issue is that in foundation.css it is getting padding-left and padding-right. You need to remove that and use margin-left and margin-right instead. And you also need to fix the width of the li. As .description will get its 100% height. So you need to include a small css in your own file (don not modify foundation.css).
#portfolio li.columns{
/* You can use the width in '%' if you want to make the design fluid */
width: 400px;
padding: 0px;
margin: 0px 0.9375em;
}
Fiddle
You'll just have to get rid of the padding on tne li
li{ padding:0 }
or use the the box-sizing property:
`li { box-sizing:border-box; -moz-box-sizing:border-box; }
Change in CSs will help,
I have updated the same in fiddle
with change in CSS,
#portfolio .description {
position: absolute;
background: rgba(0,199,134,0.8);
display: none;
width: 400px;
height: 300px;
}
#portfolio .description h1 {
color: white;
opacity: 1;
font-size: 1.4em;
text-transform: uppercase;
text-align: center;
margin-top: 20%;
width:400px;
height:300px;
overflow:hidden;
}
Update:
If the H1 created extra cutter and wrapping issue(for some), please use the DIV tag instead, which should work fine!
I hope this will solve your problem :)

Remove space between span and text element

I'm trying to make a header's background color look like a rectangular speech bubble by adding a text element ◥. Below you can see the spanned text for the background shape and the style for ◥. But this creates a blank space between the bottom of the border and the ◥, and I would like the two to line up in order to look like a speech bubble.
Image of fail in action.
http://i.imgur.com/1T09F.png
{block:Link}
<h1><span class="Headers"><a href="{URL}" {Target}>{Name} ☞</a></span>
<div class="triangle">◥</div>
</h1>
{block:Description}{Description}{/block:Description}
{/block:Link}
.triangle{
margin-left: 10px;
font-size: 35px;
color: #123033;
}
span.Headers{
display: block;
background-color: #123033;
padding: 8px
}
I tried the trick with adding a parent group in which the font size is 0, and that didn't work. Nor did setting the margin on the header to 0. Putting the ◥ div on the same line hasn't done anything either. I spent about an hour looking through other questions to see what I could do, and I couldn't find a solution, but I am nub so forgive me if I missed something obvious.
It is unreliable to use text to create the effect. Different devices will render it differently, which is not what you want.
In your case, it would be best to use an image with the same colour, placing it in a <div/> below the heading, ensuring that they touch each other. Then, add some padding on the left, as you did with the .triangle style.
I have created an image for you to use: Grab it here
All in all, your markup would look like this:
HTML:
{block:Link}
<div class="header">
<h1><a href="{URL}" {Target}>{Name} ☞</a></h1>
<div class="triangle"></div>
</div>
{block:Description}{Description}{/block:Description}
{/block:Link}
CSS:
div.header > h1 {
background-color: #123033;
padding: 8px
}
div.header > div.triangle {
background: url('Arrow.png') top left no-repeat;
height: 50px;
padding-left: 10px
}
Do let me know if this works for you.
If you're able to use generated content (which, I suppose, depends on your site's users), then I'd suggest (with the slightly amended HTML for demo purposes):
<h1><span class="Headers">a name</span></h1>​
The following CSS:
h1 {
display: block;
position: relative;
background-color: #ffa;
padding: 0.5em;
}
h1::after {
content: '';
border: 1em solid #ffa;
position: absolute;
top: 100%;
left: 2em;
border-bottom-color: transparent;
border-left-color: transparent;
}
JS Fiddle demo.
In terms of compatibility caniuse suggests that generated content is supported in IE from version 8 onwards.
References:
CSS generated content compatibility, from caniuse.com.

Resources