Viewing 11 replies - 1 through 11 (of 11 total)
  • try this?

    .hcontact {
        position: relative;
        left: 55%;
        top: 155px;
    }

    Thread Starter martinbelton

    (@martinbelton)

    Kind of works but whatever grid rescaling system that theme is using still makes behaviour of that element very different from behaviour of tagline for example. Is there any way of customizing css to include behaviour of .hcontact the same as the tagline, but aligned right? (or to include it in pages menu bar, aligned right?) I have had a look at styles.css, but don’t think behaviour is directed by css – maybe it is javascript or something?

    Thread Starter martinbelton

    (@martinbelton)

    I came across this post but twentytwelve theme doesn’t have Custom JS field in Theme Options panel – code they suggest to add here is

    jQuery( document ).ready( function() {
    var dwidth = jQuery( window ).width();
    if ( dwidth > 1000 ) {
    jQuery( '.hcontact a:first-child' ).attr( 'href', '#' );
    }
    });

    would this work if I copied the correct js file into child theme folder?

    Do not edit the theme itself. First create a child theme for your changes.

    remove the added code from where it is now (invalid location – needs to be after the body tag); and place it into the header section, for example here before this line:
    <nav id="site-navigation" class="main-navigation" role="navigation">

    then style it with:
    .hcontact { float: right; }

    Thread Starter martinbelton

    (@martinbelton)

    Would I put this into the header.php? (in child theme folder) Would I copy and paste js code as is?

    Thread Starter martinbelton

    (@martinbelton)

    @ alchymyth, just to clarify, I now have

    <code><div class="hcontact"><a href="tel:+1-800-555-5555">Call 1-800-555-5555</a> | <a href="mailto:[email protected]">[email protected]</a></div></code>

    after <html <?php language_attributes(); ?>> in header .php,

    .hcontact {
    	float: right;
    }
    .hcontact a:first-child {
    	font-size: 14px;
    }

    in edit css panel, and

    jQuery( document ).ready( function() {
    var dwidth = jQuery( window ).width();
    if ( dwidth > 1000 ) {
    jQuery( '.hcontact a:first-child' ).attr( 'href', '#' );
    }
    });

    after <nav id="site-navigation" class="main-navigation" role="navigation"> in header.php

    I am clearly confused though – as js isn’t working :/

    Do I need

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

    in head section of header.php?

    Thread Starter martinbelton

    (@martinbelton)

    Could you please help me with where it should be?

    Thread Starter martinbelton

    (@martinbelton)

    I put

    <script>jQuery( document ).ready( function() {
    var dwidth = jQuery( window ).width();
    if ( dwidth > 1000 ) {
    jQuery( '.hcontact' ).attr( 'href', '#' );
    }
    });</script>

    before <nav id="site-navigation" class="main-navigation" role="navigation"> as you suggested, and styled it with .hcontact { float: right; }, but is still outside main area.

    Thread Starter martinbelton

    (@martinbelton)

    All fixed – no jQuery needed – when you were talking about the code, I mistook which one you meant! Many thanks for your help on this ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘aligning css so elements behave nicely’ is closed to new replies.