Anchor-Link skips too far - html

At the top of a website I'm currently working on, I defined a «Skip to content»-Link with the following markup:
Skip to content
I placed this link somewhere outside the viewport, using CSS position: absolute. As soon as somebody focusses the link (when «tabbing» trough the page), the link gets moved back to the viewport and it pushes the content below down a bit, so it gets the space it needs.
#skip-to-content {
display: block;
text-align: center;
position: absolute;
top: -999px;
}
#skip-to-content:focus {
position: static;
outline: 0 none;
border: 1px solid #681;
top: 0;
}
If you now click the link, my browser skips to the content correctly, but after that the link looses focus, so the content slips up again a little bit (because the link above gets moved out of the viewport again). So in the end, you need to scroll up a little bit to see the beginning of the content. It looks, as if the anchor link would skip too far.
Is there any way I can make sure, the link always skips to the content and not some pixels below?
Please don't suggest any JavaScript-Solutions, this is basic functionality that needs to work in every browser. Thanks for your help.
— André

While not an elegant solution, try adding this to your CSS, it may give you an idea of how to fix it.
#content {
margin-top: -60px;
padding: 60px 1.1em 1.1em;/*add approx 1.1em in px for top padding here*/
}
Where 60px is the approximate added height when the skip link is visible. It's just moving the top edge of #content up a little bit. You can try different measurements to get the padding back to where it needs to be. I didn't want to suggest wrapper divs or anything, but that could work to give you the exact 1.1em top padding you originally had.
If you can figure out the exact total added height when the link is visible, use that measurement in ems instead of px.

You could just not reset the position back to static in your :focus rule.

Related

How do I make an ::after element stick to the right of the screen?

I'm doing all of this to modify an already existing website using an extension called Stylus. Also, I'm doing this on Android. I use a browser called Kiwi Browser. It supports extensions.
I'm trying to make an element that sticks to the right of the screen so as to hide the scroll indicator on Android.
I can't hide that with ::-webkit-scrollbar {display: none} or any variation of it because that element seems to be part of Android. My current solution is to add border-right: 5px solid gray !important to the body element or any element where that would work.
I exaggerated the width there a bit so it'd very visible. With that border in place, the scroll indicator becomes invisible or unnoticeable because it has the same color as the border. Now, my problem is that when I zoom in on the page, especially on the very left part of the page, that scroll indicator is noticeable again. That's why now I want to try using ::after. I'm trying to create an element that will stick to the right of screen even if I zoom in. I also don't want it to float. I want it to occupy space so that the content of the page will resize. I tried this code (which I also found here on stack) but it didn't work:
body::after{
content: " ";
position: -webkit-sticky !important;
position: sticky !important;
top: 0;
right: 0;
background: gray;
height: 100%;
width: 10px;
z-index: 9999 !important;
}
I use Kiwi Browser to read manga and comics. And the reason I want to hide that scroll indicator is because when you touch any part of the screen, that indicator appears and I can see how much is left from what I'm reading and that really ruins the mood for me.
Edit:
It seems that half of what I want to accomplish is not possible with just CSS. For reference: Prevent that a fixed element resizes when zooming on touchscreen

I have a div that I need to stay in a certain position when the screen gets smaller

I'm currently having a problem with a div on my site. I'm trying to get it to stay in a fixed position even on smaller resolutions but no matter what I have tried so far the div moves to the right every time the window gets smaller.
Here are pictures of the issue:
Correct position:
Incorrect position:
Also, here is the CSS for the div:
#fep-notification-bar{
color: #f3ed42;
border-width: 0px;
text-align: left;
background-color: #282828;
margin-left: 1338px;
font-weight: normal;
}
The site is wastelandgamers.com
If anyone knows how to resolve this issue I would really appreciate it!
EDIT:
Sorry, I wasn't clear enough and I realize now that the way I clipped the pictures makes it seem like the header is expanding but that's not the case. The new message text is what won't won't stay in place. whenever I make the screen smaller the text moves to the right instead of staying in place above the search bar. Unfortunately you can't really test it unless you are logged in and get a message.
I'm not sure what your HTML looks like but from the screenshots I would wrap all the elements up in a span or div and then position that.
Try to use float:right maybe then edit certain classes or ids using #media in the css.
I have figured out a solution for now. I have changed the code to:
#fep-notification-bar{
color: #f3ed42;
border-width: 0px;
background-color: transparent;
margin-left: 24.7%;
font-weight: normal;
position: absolute;
}
It has not completely solved my problem but it is at least a band-aid. This way the text still moves slightly, however, it now moves to the left and only a small amount so it does not fall off the page no matter how small it is.

Various CSS questions to customize theme

I'm really new to programming and trying to customize a theme that I am using. However I am having several issues where if I fix one thing something else breaks. I've researched solutions for about 3 days and I think it's time I reach out to some more experienced with CSS for help.
I tried setting up a JSFiddle but it's not working correctly as I can't access the HTML file directly. The website is www.preethijagadeesh.com. Would it be possible to review the html/css files and provide suggestions for the following requirements?
Center the title (I believe this is found in the 'site_header'
class which is pasted below). I am using margin to change the percentage and it looks
different on various browsers.
I would also like to 'fix' the title so that when I scroll the title
goes with me. I used 'position: fixed' but it cause all the
content in the 'index' ID (pasted below) to overlay on the title/site_header.
The text in the 'About' page appears to be more on the left with
a lot of white space on the right. No matter what I am unable to get
the content to center regardless of which class I update.
The line/border_bottom that appears under the navigation items should be
the same length as the text. I tried updating it but now every time
I hover over the items the text/options move around
overlay a
black color on the thumbnails on hover. I got it to 'kind of' work.
It's just when I hover on the thumbnails, the images and the
'background color' flicker
Widen the gap between the thumbnails.
Right now, there are two columns, it would be great to just put some
space in between them.
Please let me know if there's any other information I can provide.
Change
.header_image {
float: left;
margin-top: 80px;
max-width: 100%;
}
to
.header_image {
text-align: center
margin-top: 80px;
max-width: 100%;
}
Add these to .site_header:
.site_header{
/* old css remains here... */
position: fixed;
top: 0;
left: 0;
right: 0;
}
Move the padding properties from the a to their parent instead (the .page_link div).
and 5. I can't get the thumbnails to display on your jsfiddle so I can't really give the answer. But for 4 I think something like this will help:
put a <div class="thumbnail-overlay"></div> inside your thumbnail html.
For the css:
.thumbnail-overlay{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
/* this z-index should be higher than the thumbnails' child element. If no z-index is set for their child element leave it at 1 */
}
.thumbnail-overlay:hover{
background-color: rgba(0,0,0,0.5);
}
Hopefully this helps.
.header_image is floating, so you can't center it nicely. If you remove the float and then use text-align: center;, the image should center.
Not really sure where you are wanting the title to appear - should it be above the content or to the left of the content?
You have removed the padding from the links to resize the underline, but it's only been changed on hover. This is what is causing the "jumping" navigation links. If you add this code to .navigation a (instead of .navigation a:hover), this should work nicely:
.navigation a {
padding: 0;
margin-right: 6px;
margin-left: 7px;
}
Instead of using .thumb_image:hover, try using .thumbnail:hover .thumb_image and see if that's helps with the flickering. Also, maybe remove the background-position: 0 -30px;.
Is a plugin being used to generate and control the thumbnail images? The absolute positioning being used on the thumbnail images will make it difficult to reposition them.
You should be creating the site offline and reviewing your work before migrating the site to your host.
If your host does not allow you to migrate your site and/or denies you access to your HTML files, you need find a new web host.

front page height way too long without explanation

My web page http://carmentoribio.com/ for some unexpected reason is too long. there's no element that can explain that, and I know I could "fix it", but I just want to find out whats making the page scrollable so far down.
Very weird.
Your problem is the position: relative; from .megadiamond
Your elements are placed on the page and you pull them up by using position and a negative top value.
Try making them position: absolute; on this way they are moved to the top and dont affect the height of the page like before.
But a little bit of scrollbar stays there, because of the rotation of your element. There is a huge space wich it takes. Maybe you need to use some overflow: hidden;
The 4th <div class="megadiamond"> pushes page down. Check it in firebug.
.footer {
border-top: 1px solid #eee;
text-align: center;
width: 100%;
position: absolute;
bottom: 10;
padding: 1em;
}
I changed your bottom value to 10, before it was 0. In chrome your footer content overlapped with body, this change avoids that. To avoid scrolling on page change your cage max height to an adjustable value.

How to get an image to spill over the edge of a div

So, I'm getting married. Hooray!
I'm building a website for the event and HTML/CSS isn't my normal area of expertise.
I've got the site sliced and diced, and most of the important structure laid out in divs.
One thing I'm not sure of though, is that the design calls for an image to spill over both edges of the wrapper. What's the best way to do that in HTML/CSS? Or should I make the wrapper the full image width wide and make another container inside for the other content?
Thanks for your help!
Here's the design comp:
website_comp.jpg
Here's the
image that needs to spill over the
div: ribbon.png
Here's what the
site looks like now:
DierksAndEmster.com
add position:relative and overflow:visible for your #container. Then modify your menu like the following:
#menu {
background: url("http://www.dierksandemster.com/wp/wp-content/themes/et-starter-1-4/images/ribbon.png") repeat scroll 0 0 transparent;
color: black;
display: block;
float: left;
font-family: 'Walter Turncoat',arial,serif;
font-size: 20px;
height: 93px;
left: -71px;
line-height: 22px;
position: absolute;
width: 942px;
}
You could attempt to position the image with position: absolute. Another way could be to use three columns. (~50px wide left column, main area, ~50px wide right column).
You could also take a look how csswizardry has done this, it's a bit advanced though, but might be helpful: http://csswizardry.com/demos/css-powered-ribbons/
Last but not least, if you wan't to be quick and know the navigation panel that has the fancy ribbons never changes place, why not just make a big background image and build the site on top of it? :)