Edit: There is an image behind this, so adding a background color would thus obstruct the image even though it would hide the text. Thanks!
I have a fixed element on a page and a div containing text below it. When the page is scrolled, I want the text to disappear behind the fixed div but it does not. Using z-index does not work (see code). Sorry about all the text, I needed enough for the screen to scroll.
<div id="screen">
<div class="title">
About
</div>
<div class="body">
t only the beginning of a weekend away from the rigours of Primary school and learning my times tables, but also my first real social experiences. Saturday was ‘Club Day’. At around the age of 8 or 9, my Mum decided that I needed to get out into the real world and get a taste of ‘Saturday life’, and all it had to offer. So, on the advice of my much older and wiser 10 year old cousin, I chose to join the local craft club. Each Saturday morning from that day onwards, I would join the 6 or 7 other girls in the hot, cramped ‘Cathy’s Crafts’ store in Montmorency. For $7 a week I could paint pieces of wood shaped as teddies, or perhaps even stick some glitter on a nice picture for Mother’s Day. Either way it served as a warning for the rest of my life that craft was definitely nolet roll cover in my house again.” Dad wad not quite so understanding. My skills with the paintbrush were often criticised, as I had not used a ‘polyglaze’ the valiant Montmorency, who had never yet won a club championship and are likely to never achieve this coveted goal. My Saturdays had taken on a new light, a change of direction and an earlier morning wake-up. Every Saturday I would wake up early, in excited anticipation of the day ahead. Mum would check my schedule and inform me of the day’s events. Int flowers quite right, the time had come for me to give my craft club days away. Forever. And so it was that I found myself, hand glued to Mum’s, at the Little Athletics sign-up day. And so it was that I found myself being talked into being
</div>
</div>
And the CSS
#screen{
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
}
.title{
font-size: 30px;
margin-bottom: 15px;
margin-top: 110px;
text-align: center;
width: 90%;
position: fixed;
margin-left: 170px;
z-index: 3;
}
.body{
margin-top: 160px;
margin-left: 294px;
margin-right: 90px;
text-align:justify;
height: 53%;
z-index: 2;}
If you wish for the whole text to disappear you should have the "body" element be the one with overflow scroll, that way the other title element stays visible. There isn't really a way I could find to do this using a fixed div. Added a p tag around the title to align it to the bottom. and other heights were modified but this will give you a good starting place
#screen{
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:url('http://thisisarequiredfield.com/home_files/field1.jpg');
}
.title{
position:relative;
font-size: 30px;
height: 20%;
text-align: center;
float:left;
width: 100%;
z-index: 3;
}
.title p{
position:absolute;
bottom:0;
left:294px;
}
.body{
padding:0;
margin:0;
padding-left: 294px;
padding-right: 90px;
height:80%;
text-align:justify;
overflow: auto;
z-index: 2;
}
see the jsfiddle:
http://jsfiddle.net/J69Pw/5/
The background of your div is transparent so we can still see the text behind.
Do you want something like this : http://jsfiddle.net/QkGwy/
If it is, then set the background color:white to the div having 'title' class.
.title{
font-size: 30px;
margin-bottom: 15px;
margin-top: 110px;
text-align: center;
width: 90%;
position: fixed;
//margin-left: 170px;
z-index: 3;
border:1px solid;
background:white
}
And margins are also not proper in the css that's why content is visible on the upper side on title div on scroll. Correct those as well.
Related
I am using transform: skew to create the effect of a down arrow on my banner image using both the :before and :after tags. The result should look like the following:
However, in IE 9-11 there seems to be a rounding issue. At some heights there is one pixel from the background image that shows below the skewed blocks resulting in the following:
In my case, the banner is a percentage of the total height of the window. Here is the some sample code which should be able to reproduce the problem:
HTML
<div id="main">
<div id="banner"></div>
<section>
<h1>...</h1>
<p>...</p>
</section>
</div>
CSS
#banner {
position: relative;
background-color: green;
width: 100%;
height: 75%;
overflow: hidden;
}
#banner:before,
#banner:after {
content: '';
display: block;
position: absolute;
bottom: 0;
width: 50%;
height: 1.5em;
background-color: #FFFFF9;
transform: skew(45deg);
transform-origin: right bottom;
}
#banner:after {
right: 0;
transform: skew(-45deg);
transform-origin: left bottom;
}
body {
background-color: #333;
position: absolute;
width: 100%;
height: 100%;
}
#main {
max-width: 40em;
margin: 0 auto;
background-color: #FFFFF9;
position: relative;
height: 100%;
}
section {
padding: 0 1em 5em;
background-color: #FFFFF9;
}
And here a working example.
Yes, seems to be a rounding issue – and I don’t know of anything that one could do to fix this. It’s in the nature of percentage values that they don’t always result in full pixel values – and how rounding is done in those cases is up to the browser vendor, I’m afraid.
I can only offer you a possible workaround (resp. “cover up”) that seems to work – if the layout really is as simple as this, and the main content area has a white background, and no transparency or background-image gets involved there.
Pull the section “up” over the banner by a negative margin of -1px (eliminated top margin of h1 here as well, otherwise it adjoins with the top margin of the section – countered by a padding-top), so that its background simply covers up that little glitch:
section {
padding: 1em 1em 5em;
background-color: #FFFFF9;
position:relative;
margin-top:-1px;
}
section h1:first-child { margin-top:0; }
Well, if you look closely, that makes the corner of triangle look slightly “cut off” (by one pixel) in those situations where the rounding glitch occurs – if you can live with that (and your desired layout allows for it), then take it :-) (And maybe serve it to IE only by some means). If not – then sorry, can’t help you there.
Not sure if there is an issue with nested DIV that prevents scrolling or I have missed something in the code itself. At any rate cant seem to get the div with class .txtpodscroll to actually scroll. Bar appears fine just wont scroll? Below is the CSS rule I have applied to the DIV
.txtpodscroll {
font-family: Tahoma, Geneva, sans-serif;
font-size: 13px;
line-height: 20px;
width: 360px;
margin-top: 10px;
margin-right: auto;
margin-bottom: 10px;
margin-left: auto;
height: 300px;
overflow-y: auto;
overflow-x: hidden;
position: fixed;
}
<div class="holder-northeastphotobooth">
<div class="imgpod"><img src="alt-img/nephotobooth-logo.png" width="370" height="89"></div>
<div class="txtpodscroll">Photo booths are one of the most sought-after wedding reception additions, and we’ve got one of the best ready to bring to your big day. We will deliver our professional booth to your venue, assemble it, and man it for the duration to make sure your guests have a great time taking lots of memorable pictures. Afterwards, we’ll dismantle and clear away the booth. We can be as formal or as crazy as you like and will tailor it to suit your needs. You can select a range of fun green screen backgrounds for guests to choose from, allow uploading to Facebook, add multiple pictures to each print, take videos, and we can even bring along a box full of fun props for your guests to wear. Hire our booth and you’ll get unlimited pictures and prints on the night, plus we’ll give you a USB stick with all of the pictures on to take away and for a limited time we’ll even supply a 2nd set of prints in a lovely photo album for you to take home and treasure. </div>
</div>
Plus this is a link to it live and not working.
http://www.yourwedding.com/yourweddingwow/index-northeastphotobooth.html
it's because the book's inner shadow is above the scrollbar, so you cannot click it, but you still see it because the shadow is a transparent PNG...
change this line:
standard-variable.css (line 83)
.holder-northeastphotobooth {
float: left;
font-family: Arial,Helvetica,sans-serif;
height: 470px;
margin: 0;
padding: 15px;
position: relative; /* added */
width: 370px;
z-index: 1; /* added */
}
Make sure to remove the background property as well, so the shadow will be shown "under" the page, and not above it. try it on firebug and see, it's very easy to fix.
you have a div with a class of .wowbook-gutter-shadow that you have placed on top of the scroll bar, this is why it doesn't scroll
if you give .txtpodscroll the following style: z-index:2 it should fix your problem
To prevent scroll you should use "percentage".
.txtpodscroll {
font-family: Tahoma, Geneva, sans-serif;
font-size: 13px;
line-height: 20px;
width: 360%;
margin-top: 10px;
margin-right: auto;
margin-bottom: 10px;
margin-left: auto;
height: 300px;
overflow-y: auto;
overflow-x: hidden;
position: fixed;
}
if the scroll is horizontal.
width: 360%;
Hope this helps.
I feel like this should be (and probably is) answered somewhere, but either that's not the case, I'm not searching the right way, or it's some closely guarded national secret, because I cannot find an answer that works. Specifically, I cannot find an answer that accommodates the image on the left side of my div.
What I'm trying to effect is for the text to be centered horizontally with regards to the entire screen and vertically within the 'header' div. I don't want to use my logo as a background, because I'm using it as a home anchor. I have tried to using 'display: table-cell' and 'vertical-align: middle' to disastrous result. Please, any advice/help/link is appreciated.
CSS:
#header{
width: 85%;
min-width: 500px;
text-align: center;
margin-left: auto;
margin-right: auto;
overflow: hidden;
background-color: #fff;
border-bottom-width: 10px;
border-bottom-style: double;
border-bottom-color: #000;
}
#title{
width: 85%;
margin-left: auto;
margin-right: auto;
position: absolute;
display: table-cell;
vertical-align: middle;
}
#logo{
float: left;
padding-right: 1em;
width: 150px;
}
HTML:
<div id="header">
<img id="logo" src="../images/logo.jpg" alt="Widget News" />
<span id="title"><h1>Site Title</h1></span>
</div>
Also, I'm completely new to using CSS (and pretty useless with xhtml/html5). I'm working on my current project as a means to familiarize myself with CSS/PHP/HTML/JScript, and so far, the CSS/HTML is the only part that I'm having problems with. Any pointers to a good beginner's, but not remedial/'for dummies', guide would also be appreciated.
I'd recommend making your logo absolutely positioned. That will take it out of the flow of the html elements (like a background image does) while keeping it still clickable.
#logo {
position: absolute;
top: 5px;
left: 10px;
width: 150px;
}
That will make it easier to center your title. Here's the full example with a few adjustments to your code:
http://jsfiddle.net/gqvUv/
Your "text-align: center;" keeps everything centered horizontally, and adjusting the line-height of your h1 will work to center it vertically, as long as the title is just one line.
It's easy to get confused by relative and absolute positioning, but this tutorial makes it clear: http://www.barelyfitz.com/screencast/html-training/css/positioning/
Finally, this is my go-to article on centering things with CSS: http://designshack.net/articles/css/how-to-center-anything-with-css/
I'm back with more questions!
It's likely something very simple, but it has confused the hell out of me. I have a layout set-up so that the H2 text on pages and posts (Wordpress) has a background image next to it on both sides, accomplished by use of span:before and span:after.
Here is how it is working correctly and what I would like the overall CSS to achieve:
http://www.weburton.co.uk/content/demo/?page_id=121
This is currently achieved by min and max-widths in the CSS. And I've had the width part set to auto, where it is under a parent element with the width of the page. I don't understand how the lines aren't automatically resizing based on the H2's width. See, the problem here:
http://www.weburton.co.uk/content/demo/?p=36
Here is the CSS that is used:
#pagewrapper{
width: 960px;
margin: 0 auto;
position: relative;
padding-top: 140px;
text-transform: uppercase;
}
h2 span:before{background:url("http://weburton.co.uk/content/demo/wp-content/themes/epic/images/header_bg.jpg") repeat-x scroll left center transparent;content:" ";height:1px;margin-right:15px; left: 0%; position:absolute; margin-top: 15px; min-width: 25%; max-width: 50%; width: auto; }
h2 span:after{background:url("http://weburton.co.uk/content/demo/wp-content/themes/epic/images/header_bg.jpg") repeat-x scroll right center transparent;content:" ";height:1px; margin-left:15px; right: 0%; position:absolute; min-width: 25%; max-width: 50%; width: auto; margin-top: 15px; }
Basically, I've exhausted all options that I can think of. Is there something I'm missing here or is there another way to go about achieving this styling using something else but span that is easier?
Oh and I know I have some redundant styling calls, I'm in the process of cleaning it up. :)
Thanks in advance! :)
May be that is what you want
Remove min-width and max-width from h2 span:before and h2 span:after
h2 span {
position:relative;
}
h2 span:before {
left: -25%;
width: 20%;
}
h2 span:after {
right: -25%;
width: 20%;
}
without a fiddle it's hard to give you a definite answer, but I think that if you try changing the display property to display: inline-block it should do the trick.
This will cause the element to act as a block element while still being displayed inline (thus preserving your current layout - block elements typically take up the full available width and are followed by linebreaks).
If you have a quick look at this website that I am designing: http://milabalami.com
The blackline seen in the footer is the one that I want to fix. Is there anyway that I can put that footer at the bottom of the content (wrapper) of the page? I have not done any webdesigning since the golden days of tables so CSS is quite new to me.
Anyone that could assist this old man? Please be specific in any reply as I am new to CSS styling...
you mean that you want to eliminate the gap between wrapper and the black line? If yes just change the #blackbox2 margin to margin: 0 auto 15px;
You have:
#blackbox2 {
background-color: black;
bottom: 0%;
height: 33px;
margin-bottom: 15px;
margin-left: auto;
margin-right: auto;
margin-top: 11%;
position: relative;
top: auto;
width: 900px;
z-index: 12;
}
Try removing margin-top: 11%. This matches to '11% of the parent height', which is why your blackbox2 is so far from the wrapper above it.
Does this solve your problem — http://www.cssstickyfooter.com/ ?