Results 1 to 7 of 7

Thread: Cant stop opacity inheritance on an image.

  1. #1
    Join Date
    Mar 2007

    Question Cant stop opacity inheritance on an image.

    Hi Guys,

    Im going round in circles here with this..

    I have a Div and have its opacity set to 0.7 in my style sheet so I can see slightly through it...this is fab!!!

    But in the div I have a thumbnail image and its also showing the opacity setting of the div and I dont want this.

    I tried to put the image in its own div and set the css to like opacity=1
    I also make a class for the image and set it to the same opacity=1

    None of these ideas has worked.

    I would appreciate any thoughts on how to stop the inheritance on my thumbnail.

    Regards as ever :-)

  2. #2
    Join Date
    Feb 2012
    Bokaro Steel City (Jharkhand), India!
    Yes, this is a problem with 'opacity'.

    It is inherited only in decreasing manner!

    I mean this will work:
    HTML Code:
    <div style="opacity:0.6">
        Main div first part!
        <div style="opacity:0.3">
            Sub div part!
        Main div last part!
    But this won't work:
    HTML Code:
    <div style="opacity:0.3">
        Main div first part!
        <div style="opacity:0.6">
            Sub div part!
        Main div last part!
    The other day I heard a guy saying that 'jQuery' might be used to resolve this issue!

    But I do not know anything about that!

    "It will never rain roses: when we want to have more roses, we must plant more roses." - George Eliot

  3. #3
    Join Date
    Mar 2007


    Hi M8,
    Its just not happening for me..
    I tried it the way you suggested like this..

    width: 600px;
    	height: 400px;
    	border:1px solid #CCC;
    	filter:alpha(opacity=60); /* For IE8 and earlier */
    	color: #FFF;
    	display:block;    /*set the div in the center of the screen*/
    	filter:alpha(opacity=30); /* For IE8 and earlier */
    Then my HTML

    <div id="BoxContainerPopup1">
        Main div first part!
        <div id="thumbdiv" ><img src="images/me.jpg" width="269" height="267" /></div>
        Main div last part!
    Am I missing something?

    Regards as ever :-)

  4. #4
    Join Date
    Dec 2005
    This is not a problem with opacity, it is this way by design. Nothing can 'fix' it because nothing is wrong with it. What you have to do is use it the way it was designed to be used (which sometimes requires working around what seems to be a problem with the way opacity was designed to work):

    HTML Code:
    <div id="parent">
      <div class="semi-transparent"></div>
      <div class="opaque">
         Content Content
      <img src="thumb.jpg">
         Content Content
    #parent { position: relative; }
    #parent .semi-transparent { position: absolute; top:0; left:0; right:0; bottom:0; background: #fff; opacity: 0.7; z-index: 1;}
    #parent .opaque { position: relative; z-index: 2; }
    With CSS3 you can actually use rgba and do this:

    #parent { background: rgba(255,255,255,0.7); }
    And you don't need the semi-transparent div/workaround - but this won't work in IE7/8.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...

  5. #5
    Join Date
    Mar 2007

    Thumbs up

    Thanks aj_nsc's

    Im sorry to be slow to respond its been one of those days, Im sitting trying your example now and its looking great except doesnt seem to work in IE im having to click the compatability button for it to work. Works in chrome and firefox though, have i missed something for IE to do it without the need of the compatability view as most people i know wouldnt know to need t hit it?

    I need to read some more on the new css :-)

    Thanks .
    Last edited by TagUK2006; 03-03-2012 at 08:24 PM.

  6. #6
    Join Date
    Dec 2005
    That's because IE<9 doesn't use opacity it uses filter: alpha(opacity), but because you didn't use that in your original post, then I assumed you must've known about it or didn't care about it.

    div { opacity: 0.7; } //IE>9 and non-IE
    div { filter: alpha(opacity=70); } //IE<9
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...

  7. #7
    Join Date
    Mar 2007

    Thumbs up

    Thanks aj_nsc's ,

    That got it :-)

    I did have that origonaly but when I read your post and didnt see it in your code I figured Id follow what you were saying and not need it.

    I get in a pickle at times with all the browsers old and new and whats what with what i all need to remember, so I appreciate this forum.

    Can you reccomend a good site I can use as an aid in reading material on all the main differences I should always remember between the browsers and css needed to keep each happy in given circumstances.

    Thanks again

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13285 seconds
  • Memory Usage 2,905KB
  • Queries Executed 15 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (5)bbcode_code
  • (3)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (7)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates