Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9

Thread: Odd CSS problem

  1. #1
    Junior Member Stopdoor's Avatar
    Join Date
    Aug 2011
    Posts
    14
    Member #
    28990
    Liked
    1 times
    Alright, just a hopefully minor problem here, not really sure how to classify it.

    a{color:#363636; text-decoration: underline;}
    h4{color:red;}
    img{margin-left:auto; margin-right:auto; border: ridge; border-color:red;}

    This is a section of my css code. Obviously I'm trying to apply these properties to each object.

    But only the h4 tag is recognized. 'a' and 'img' tags aren't affected by these. I haven't tried other tags, but I find it odd that one obviously works when it's formatted the same way and the others don't. Any obvious problems here?

  2.  

  3. #2
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    h4{color:red;}. Should be. H4{font-color:red;}. Or h4{font-color:#0000ff}

    You probably shouldn't mix named colors with rgb colors.

    As for the img tag, using margin:auto; normally kicks the browser into quirk mode, margins in my experience should always have a defined entry to work as intended.

    Also if your page doesn't have a valid doc type declared some CSS elements are hit and miss if they work or not.

  4. #3
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    Just realized the border:ridge; was there, try border:3px solid red; see if that works, again, without a valid doc type declared it's hit or miss.

  5. #4
    Junior Member Stopdoor's Avatar
    Join Date
    Aug 2011
    Posts
    14
    Member #
    28990
    Liked
    1 times
    The h4 tag works fine, so it's not the problem. The other two are the problems.

    I'm using auto-margins for alot of my divs and such and they work fine, so I don't see why that would be a problem.

    I changed the img css to
    img{border:3px solid red;}
    and still got no effect.

    and wouldn't doctype be
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">?
    Would using the strict doctype affect me?

  6. #5
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    color:red should work fine. Color sets the foreground color, which affects the text color. Also, red is #ff0000

    That said, could you post the rest of the code? HTML as well? It would go a long way in helping you.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  7. #6
    Junior Member Stopdoor's Avatar
    Join Date
    Aug 2011
    Posts
    14
    Member #
    28990
    Liked
    1 times
    Alright, so I may have solved my non-responsiveness issue. Turns out I had an img class at the bottom I had long forgotten about that erased borders, so it killed the border commands. The 'a' class actually does work.

    So now I need to work more on syntax. Can I center images using a class? While I can make a red 3px solid border, using 'text-align' or 'margins:auto' doesn't seem to work in centering them.

    I also am trying to get some pages to display dark-coloured links and others light-coloured links. Is it possible to declare/create a CSS class in the body? My head tags are part of a universal template, so they all use the same CSS, unless I state otherwise in the body with style attributes. But I can't create CSS class in that attribute or specify a class for every link, can I?

  8. #7
    Junior Member Stopdoor's Avatar
    Join Date
    Aug 2011
    Posts
    14
    Member #
    28990
    Liked
    1 times
    So I ended up fixing the image-centering deal, just by adding 'display:block' along with auto margins it centered them all nicely.

    My second question about CSS classes defined in the body still stands, though.
    m3n0tu18 likes this.

  9. #8
    WDF Staff m3n0tu18's Avatar
    Join Date
    Jul 2011
    Location
    Devon, UK
    Posts
    1,473
    Member #
    28473
    Liked
    265 times
    Thanks for answering the question when you came to a solution. There's many that just say "don't worry I've fixed it" and don't tell us how. Telling how benefits us and others coming to the site for info =)

    Thanks very much
    If you like my comments to your thread please click the LIKE button

    Check out my portfolio: Here!
    View my company Facebook Page
    View my company Website

    <<Plrease ignoer my typo's I have isdexlyia>>

  10. #9
    Junior Member Stopdoor's Avatar
    Join Date
    Aug 2011
    Posts
    14
    Member #
    28990
    Liked
    1 times
    Well after research it seems that style tags DO work in the body, it's just not recommended.

    But I ended up figuring out how to set up a class like 'div.linkwhite a{colour:white}' and applying that. Took awhile especially when running into kinks with ids vs classes. When people tell you they're the same except ids are meant to be used once, don't believe them.

    So I'm good yeah.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:18 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com