Menu
  • HOME
  • TAGS

Is there a way to get my anchor links to appear below my header?

Tag: html,css,css3

I've been handed the reigns on a website that is having issues with anchored tags not displaying correctly when a page is loaded from the FQDN. That is if I reference http://www.foo.com/news#bar the entire div for bar will be hidden behind the header. Where if I use the anchor tag from within the page itself (that is, I click the link for #bar at the top of the page) it'll scroll to the top of the div as intended. I should note, that the link that works on the page, and the link with the FQDN are both available on the same page, and clicking the FQDN (even on the same page) will always cause the display issue.

Edit:

Ok in the interest of getting reference code up this is a cleaned up sample of the output from the CMS. I've omitted quite a bit but kept the relevant structure, CSS will be below this:

<html>
    <body class="html not-front not-logged-in one-sidebar sidebar-second page-point page-point- page-point-19 point-type-inside-page">
        <div id="skip-link"></div>
        <div id="wrapper">
            <header id="header" class="header-holder">
                <div class="wrap">
                    <div class="top-menu">
                        <div class="social"></div>
                        <div class="top-nav"></div>
                        ::after
                    </div>
                    <div class="logo"></div>
                    <div class="main-nav">
                        <a class="opener" href="#">
                            <span></span>
                        </a>
                        <div class="js-mobile-slide" style="max-height: 838px;">
                            <ul class="js-slide-hidden">
                                <li class="first expanded menu-mlid-490">
                                    <a href="/foo#bar">Our target!</a>
                                    <ul></ul>
                                </li>
                                <li class="expanded active-trail active menu-mlid-495"></li>
                                <li class="last expanded menu-mlid-496"></li>
                            </ul>
                            <div class="menu-mobile js-slide-hidden"></div>
                        </div>
                    </div>
                    ::after
                </div>
                ::after
            </header>
            <main id="main" role="main">
                <div class="page-navigation">
                    <div class="wrap">
                        <div class="region region-page-navigation">
                            <div id="block-views-inside-page-block-1" class="block block-views page-menu clearfix clearfix">
                                <div class="block-content">
                                    <div class="view view-inside-page view-id-inside_page view-display-id-block_1 view-dom-id-9">
                                        <div class="view-content">
                                            <ul>
                                                <li class="views-row views-row-1 views-row-odd views-row-first anchor-active">
                                                    <a href="#Foo">Foo</a>
                                                </li>
                                                <li class="views-row views-row-2 views-row-even">
                                                <a href="#bar">Bar</a>
                                                </li>
                                                <li class="views-row views-row-3 views-row-odd"></li>
                                                <li class="views-row views-row-4 views-row-even views-row-last"></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                ::after
                            </div>
                            <div id="block-views-inside-page-block" class="block block-views btn-holder clearfix clearfix"></div>
                        </div>
                        ::after
                    </div>
                    ::after
                </div>
                <div class="content-holder">
                    <div class="wrap">
                        <section id="content" class="content-block ">
                            <a id="main-content"></a>
                            <div id="tabs-wrapper" class="clearfix"></div>
                            <div class="region region-content">
                                <div id="block-system-main" class="block block-system clearfix clearfix">
                                    <div class="block-content">
                                        <div id="point-19" class="point point-inside-page clearfix" typeof="sioc:Item foaf:Document" about="/overview">
                                            <span class="rdf-meta element-hidden" content="content" property="dc:title"></span>
                                            <div class="content clearfix">
                                                <div class="field-collection-container clearfix">
                                                    <div class="field-collection-view clearfix view-mode-full">
                                                        <section id="foo" class="text-block section-active"><p>First content to appear</p></section>
                                                        ::after
                                                    </div>
                                                    <div class="field-collection-view clearfix view-mode-full">
                                                        <section id="bar" class="text-block"><h1>Test</h1><p>this will wind up hidden</p></section>
                                                        ::after
                                                    </div>
                                                    <div class="field-collection-view clearfix view-mode-full"></div>
                                                    <div class="field-collection-view clearfix view-mode-full field-collection-view-final"></div>
                                                    ::after
                                                </div>
                                                ::after
                                            </div>
                                            ::after
                                        </div>
                                    </div>
                                    ::after
                                </div>
                            </div>
                        </section>
                        <aside id="sidebar" class="sidebar"></aside>
                        ::after
                    </div>
                </div>
            </main>
            <footer id="footer" class="footer"></footer>
        </div>
    </body>
</html>

And now for the CSS as pulled from Firebug:

.clearfix::after{
    content: ".";
    display: block;
    height: 0px;
    clear: both;
    visibility: hidden;
}

.content-block{
    width: 75%;
    float: left;
    padding: 53px 0px 32px;
}

.content-block h1 {
    font-size: 29px;
    line-height: 24px;
    margin: 0px 0px 15px;
}

.content-block .text-block {
    text-align: left;
    padding: 0px;
}

.header-holder{
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    z-index: 12;
    background: #FFFF non repeat scroll 0% 0%;
    border-bottom: 1px solid;
    box-shadow: 0px 1px 2px;
}

.header-holder .wrap {
    padding: 0px 15px;
}

.header-holder .logo {
    margin: -1px 0px 0px 14px;
}

.js-mobile-slide {
    max-height: none !important;
    overflow: visible;
}

.main-nav .js-mobile-slide > ul {
    display: block !important;
    position: static !important;
}

.main-nav .js-mobile-slide > ul {
    font-size: 18px;
}

.point-type-inside-page h1.page-title{
    display: none;
    visibility: hidden;
}

.page-menu {
    font-size: 16px;
    padding: 11px 0px 0px;
    float: left;
    width: 60%;
}

.page-navigation {
    min-height: 60px;
}

.page-navigation {
    position: fixed;
    top 112px;
    width: 100%;
    z-index: 10;
    padding: 14px 0px;
}

.top-menu {
    width: 100%;
    padding: 11px 0px 0px;
    text-transform: uppercase;
}

.top-menu ul, .main-nav ul, .top-slideshow .pagination ul, .info-menu ul, form .item-list ul, .page-navigation ul, .list-holder ul, .benefits-list ul, .explanation-list ol, .explanation-list ul, .pricing-list ul, .list-info ul, .footer ul {
    margin: 0px;
    padding: 0px;
    list-style: outside none none;
}

.wrap {
    max-width: 1030px;
    padding: 0px 15px;
    margin: 0px auto;
}

#block-system-main .field-collection-container, #block-system-main .field-collection-view {
    border-bottom: medium none;
    margin: 0px;
    padding: 0px;
}

#header .main-nav .js-mobile-slide > ul > li {
    display: inline-block;
    vertical-align: top;
    margin: 0px 0px 0px 45px;
    padding: 0px 0px 22px;
    position: relative;
}

#wrapper{
    width: 100%;
    overflow: hidden;
    padding: 186px 0px 0px;
}

article, aside, details, figcaption, figure, footer, header, main, nav, section, summary {
    display: block;
}

html, body, div, span, applet, embed, object, iframe, frameset, p, q, blockquote, sub, sup, a, abbr, acronym, font, img, small, center, h1, h2, h3, h4, h5, h6, b, strong, big, u, ins, i, cite, em, var, dfn, address, s, strike, del, dl, dt, dd, ol, ul, li, pre, code, kbd, samp, tt, fieldset, legend, form, label, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video {
border: 0px none;
}

h1 {
    font-size: 200%;
}

h1 {
    font-size: 39px;
    font-weight: normal;
    text-transform: capitalize;
}

h1, h2, h3, h4, h5, h6, b, strong, th {
    font-weight: bold;
}

*{
    margin: 0px;
    paddin: 0px;
    max-height: 1000000px;
}

*, *::before, *::after {
    box-sizing: inherit;
}

I do want to point out that there's some magic going on here with jQuery and some smooth scrolling that won't appear just cutting and pasting this sample code into an HTML file.

Best How To :

Not a lot of information to go on, but it sounds as if you have an "on load" Javascript routine writing the header. So you scroll to the anchor and then overwrite it.

If you can instead invoke the Javascript directly from the start of the body, so that the header is created before the rest of the body, you should get the behaviour you want. (If you can't, because the header Javascript does things with the rest of the body, then more significant rework will be required.)

CSS - Linear Gradient Background Color no-repeat is not working for if it has multiple tds

html,css,css3

table{border-collapse:collapse;width:100%} table tr td{padding:5px;border:1px solid #000; background:#FFF } table tr:hover td{padding:5px;border:1px solid #000; background:transparent } table{ background:...

HTML elements in Angular bindings expression

html,angularjs

You could use ng-show, it will show the paragraph if employee.firstname is null. <tr ng-repeat="employee in employees"> <td>{{employee.firstname }}<p ng-show="!employee.firstname" style="color:red">No name</p></td> <td>{{employee.job}}</td> </tr> ...

Get elements containing text from array

javascript,jquery,html,arrays,contains

You can use :contains selector. I think you meant either one of those values, in that case var arr = ['bat', 'ball']; var selectors = arr.map(function(val) { return ':contains(' + val + ')' }); var $lis = $('ul li').filter(selectors.join()); $lis.css('color', 'red') <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <ul> <li>cricket bat</li> <li>tennis ball</li> <li>golf ball</li>...

Click on link next link should be display on same page

javascript,php,jquery,html,css3

Ok, so i tried to decypher what you meant with your Question. To Clarify: He has this one page setup. inside the div Our Project, there are two Buttons or links Visit more. When clicked, he wants the About Section to be shown. All in all it is impossible for...

Adding horizontal space between 2 buttons using javascript

javascript,jquery,html,css

Use CSS instead of Javascript. Anyway, you're adding a class to all buttons. Use following code: .submitButton { margin: 0 10px; } ...

Changing font-size of
  • on wordpress
  • css,wordpress,html-lists

    I think you have style inheritance from upper element, check it with dev. tools in browser. You can also try to set inline style for: <li style: "font-size: 22px;">Name 1</li> or add !important in your css file, like this: td > ul li { font-size: 22px !important;"> } ...

    Centering navbar pills vertically within the navbar using flexbox

    html,css,twitter-bootstrap,flexbox

    Set display: flex for the <ul class="nav">, not for items. Also use align-items: center for vertical aligment: .nav { height: 70px; display: flex; justify-content: center; align-items: center; } <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/> <div class="container"> <nav class="navbar navbar-default navbar-fixed-top"> <ul id="nav_pills" class="nav nav-pills" role="tablist"> <li role="presentation"> <a href="/">About</a> </li> <li...

    Automatically calling server side class without

    javascript,html,ajax

    Trigger the click event like this: $('._repLikeMore').trigger('click'); ...

    copy last column of one table to another table based on some condition

    jquery,html

    I modified your code based on your requirement.please check it once. rowCount = $('#table3 tr:last').index() + 1; table4rowCount = $('#table3 tr:last').index() + 1; row = rowCount + 1; var pivot_1 = 1001; var loop = 0 $("#table4 tr:eq(0)").find("th:last").after("<th>Total_col</th>"); for(i=1;i<row; i++) { var d = $('#table3 tr:eq(' + i + ')').find("td:eq(1)").text();...

    How to set DIV's width based on CSS indexes

    html,css

    If I understand this correctly,all you need to do is change your CSS to the following: .sintesi-offerta > .block:nth-child(3n+1) { width: 40%; } .sintesi-offerta > .block:nth-child(3n+2) { width: 20%; } .sintesi-offerta > .block:nth-child(3n+3) { width: 40%; } Side note: your br tags should be <br/> for jsfiddle to interpret them...

    Setting radio button checked true on button click

    javascript,jquery,html

    Here is an example : http://jsfiddle.net/xhhLja7m/ $(".choice-option").click(function() { $(this).find('input[type=radio]').prop("checked", "true"); }) ...

    tag in HAML

    html,css,haml

    HAML equivalent is %i{class:"fa fa-search"} You can look at http://codepen.io/anon/pen/BNwbEP and see the compiled view ...

    Div with the form of a pencil [duplicate]

    html,css,css-shapes

    .pencil{ width: 200px; height: 40px; border: 1px solid #000; position: relative; } .pencil:before{ content: ''; display: block; margin: 10px 0; width: 100%; height: 10px; border: 6px solid #000; border-width: 6px 0; } .pencil:after{ content: ''; display: block; height: 10px; border: 1px solid #000; border-width: 1px 1px 0 0; width:...

    Background-image style with JS not working in ie9

    javascript,jquery,html,internet-explorer

    Your call of setTimeout fails in any browser, but in IE9 with an exception(what stops the further script-execution). It's a matter of time. At the moment when you call var timer = setTimeout(slideshow, 8000); slideshow is undefined , and undefined is not a valid argument for setTimeout. Wrap the call...

    Dynamically select from a dynamically generated dropdown

    php,html,select,drop-down-menu

    It is because you aren't ending the value attribute, so your selected option becomes <option value="optionvalueselected" -- 'optionvalue' being the value of your selected option, and 'selected' being the attribute you want to set, but won't be set because you never ended value The following should work: <select name="course_id" id="course_id">...

    How to remove unmatched row in html table using jquery

    jquery,html

    Try this solution: var notrem = []; $('#Table1 tr').each(function(){ var currentRowHTML = $(this).find("td:first").html(); $('#Table2 tr').each(function(i){ var c= $(this).find("td:first").html(); if(c == currentRowHTML ){ notrem.push(i); } }); }); $('#Table2 tr').each(function(i){ if(notrem.indexOf(i) < 0){ $(this).remove(); } }); Explanation: First gather all indexes of Table2 that are equal and are not to be removed....

    CSS :hover that shows more than one image

    html,css,css3

    Okay so I have got a probable solution, the catch is, you won't be able to use img tags. You can use images as background-image and animate background on :hover NOTE: Fade in effect can be removed by playing with animation. HTML <div class="image-box"></div> CSS .image-box { height: 200px; width:...

    How to remove all the borders of a selectbox?

    jquery,html,css,drop-down-menu

    Firefox has some problems with select-background. You can try this code - it'll remove the arrow, and then you can add a background image with your arrow (I took an icon from google search, just put you icon instead) I get this on FireFox (You can use any arrow icon...

    Top header 100% of screen, but body only 70%?

    html,css

    Put your header inside the body. And don't apply styles to the body but use a container. + You should have one single header in your page. <body> <header> <nav><ul> <li class="active"><a href="#">Home</a></li> <li><a href="#">Solutions & Services</a> <ul> <li><a href="#">Internet</a></li> <li><a href="#">Networking</a></li> <li><a href="#">Website</a></li> <li><a href="#">Home...

    Website showing differently in windows xp and mobile

    html,css

    The background colour changes when the browser width is less than 1200px wide. You have specified the background-color for the selector .td-grid-wrap within a media query: What you need to do is move the background-color property to the non-media-queried selector .td-grid-wrap or perhaps .td-page-wrap. ...

    How to make background body overlay when use twitter-bootstrap popover?

    html,css,twitter-bootstrap

    Posting some more code would be nice. This should work. Use some jQuery or AngularJs or any other framework to make the .overlay initially hidden, then to make it visible when needed. If you need help, comment. If it helps, +1. EDIT $(function() { $('[data-toggle="popover"]').popover({ placement: 'bottom' }); $("#buttonright").click(function() {...

    How To Check Value Of String

    javascript,css,string,numeric

    document.GetElementById("tombolco").style = "display:block"; That's not the right way. This is document.getElementById("tombolco").style.display = 'block'; Also note that it is getElementById, not with a capital G. Same with 'none',Rest of your code is fine. Fiddle...

    HTML CSS Two 2-column tables side by side with same height and width

    html,css

    Okay so I have made a few assumptions to create this solution. Firstly, I'm guessing that as you are setting the headers of the tables as width:200px; that the width of the two columns are 100px. (This can be changed if need be). Secondly, these tables are not floated. This...

    Google map infowindow position on custom marker

    javascript,css,google-maps,google-maps-api-3

    Set the pixelOffset of the InfoWindow appropriately: From the documentation on InfoWindows pixelOffset | Type:Size | The offset, in pixels, of the tip of the info window from the point on the map at whose geographical coordinates the info window is anchored. If an InfoWindow is opened with an anchor,...

    change css dynamically by selecting dropdown list item

    jquery,html,css,drop-down-menu

    I have created a working example for you. You can find the jsfiddle in here This piece of code uses JQuery. (Remember, for these type of tasks, JQuery is your friend =] ). HTML <select id="dropDownMenu"> <option value="option1" selected="selected">yes</option> <option value="option2">no</option> </select> <br> <img id="picture" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f5/House_Sparrow_mar08.jpg/220px-House_Sparrow_mar08.jpg"> Javascript function changeStyle(){...

    show div only when printing

    javascript,html,css

    You need some css for that #printOnly { display : none; } @media print { #printOnly { display : block; } } ...

    How do I display my mysql table column headers in my php/html output?

    php,html,mysql,table,data

    Note: You can just make a single file out of it to achieve your wanted output Use mysql_real_escape_string() to sanitize the passed-on value to prevent SQL injections You should use mysqli_* instead of the deprecated mysql_* API Form them in a single file like this (display.php): <html> <form method="post" name="display"...

    show/hide an overflow div on anchor

    javascript,jquery,html,scroll

    I've just updated your jsfiddle: http://jsfiddle.net/0sq2rfcx/8/ This should work on all browsers included IE7 $('#b1').click(function () { $('#result').show(); $("#result").animate({ scrollTop:$('#a1').parent().scrollTop() + $('#a1').offset().top - $('#a1').parent().offset().top}, "slow"); }); $('#b2').click(function () { $('#result').show(); $("#result").animate({ scrollTop:$('#a2').parent().scrollTop() + $('#a2').offset().top - $('#a2').parent().offset().top}, "slow"); }); $('#b3').click(function () { $('#result').show();...

    submitting form then showing loading image by javascript

    javascript,html

    Let suppose on button click you are calling ajax method <button onclick="LoadData();"/> before ajax call show image and onComplete ajax method hide this image function LoadData(){ $("#loading-image").show(); $.ajax({ url: yourURL, cache: false, success: function(html){ $("Your div id").append(html); }, complete: function(){ $("#loading-image").hide(); } }); } ...

    bootstrap - dynamically changing jumbotron background image

    javascript,jquery,html,css,bootstrap

    You have some syntax errors otherwise everything is good!! keep url inside quotes as below: $('.jumbotron').css('background-image','url(/path/to/new/image)'); ...

    Target next instance of an element/div

    javascript,jquery,html

    nextAll and first: $(this).nextAll('.hidden').first().slideToggle(...); This question has more about this: Efficient, concise way to find next matching sibling?...

    why i don't get return value javascript

    javascript,jquery,html,json,html5

    the first "A" in AJAX stands for "Asynchronous" that means, it is not executed right after it has been called. So you never get the value. Maybe you could first, get the os list and then output what you need, like this: function createCheckBoxPlatform(myDatas) { $.ajax({ url: "/QRCNew/GetOS", type: "post",...

    Dynamically resize side-by-side images with different dimensions to the same height

    javascript,html,css,image

    If it's responsive, use percentage heights and widths: html { height: 100%; width: 100%; } body { height: 100%; width: 100%; margin: 0; padding: 0; } div.container { width: 100%; height: 100%; white-space: nowrap; } div.container img { max-height: 100%; } <div class="container"> <img src="http://i.imgur.com/g0XwGQp.jpg" /> <img src="http://i.imgur.com/sFNj4bs.jpg" /> </div>...

    Detect when the jQuery UI slider is being moved?

    jquery,html,css,jquery-ui

    You can use 3-Events: - Start (Start-Sliding) -> Stop Player - End (End-Sliding) -> Start Player - Slide (Sliding) -> Move Player-Position $("#range").slider({ range: "min", start: function(event, ui) { player.pauseVideo(); }, stop: function(event, ui) { player.playVideo(); }, slide: function(event, ui) { player.seekTo(ui.value,true); return false; } }); Demo: http://codepen.io/anon/pen/EjwMGV...