• Link1
  • Change background image opacity while preserving visibility of child elements-PHP Chinese Network Q&A
    Article Topic Learning Download Q&A Programming Dictionary Game Recent Updates
    LOGIN
    简体中文(ZH-CN) English(EN) 繁体中文(ZH-TW) 日本語(JA) 한국어(KO) Melayu(MS) Français(FR) Deutsch(DE)
    • Back-end Development
    • Web front-end
    • Web3
    • Frequently Asked Question
    • Mobile Game Tutorial
    • Database
    Front-end
    HTML | CSS | JavaScript | Vue.js
    rear-end
    PHP | ThinkPHP | Laravel | MySQL | Redis
    Latest Recommendations
    • Php8, I'm coming too

      84669 person learning

    native foundation
    HTML | CSS | HTML5 | CSS3 | JavaScript
    framework development
    jQuery | Vue.js | React | AngularJS | Node.js | BootStrap | AJAX | Foundation
    Latest Recommendations
    • Learn website layout in 30 minutes

      152542 person learning

    Programming language
    PHP | Python | Go | Java | C | C++ | C# | VBSscript | Scala | Lua | Perl | Ruby | JSP | XML | ASP
    framework/Tool
    ThinkPHP | Laravel | Servlet | Django | ASP.NET
    Introduction to Fundamentals
    MySQL | SQL Server
    Advanced learning
    MongoDB | Oracle | Redis | Memcached
    Latest Recommendations
    • Shangguan Oracle Beginner to Proficient Video Tutorial

      20005 person learning

    Native development
    Android | iOS
    Multi terminal development
    Swift | Flutter | uni-app | Applet | Other
    Latest Recommendations
    • Your first line of UNI-APP code

      5487 person learning

    • Flutter from scratch to app launch

      7821 person learning

    Environmental Use
    Linux | Docker
    Tool usage
    PhpStudy | Git | Other tools
    Latest Recommendations
    • Brother Lian New Linux Video Tutorial

      359900 person learning

    Ui Design
    Axure | PS
    Latest Recommendations
    • AXURE 9 Video Tutorial (Suitable for Product Manager Interactive Product Design UI)

      3350 person learning

    • Zero Basic Proficiency PS Video Tutorial

      180660 person learning

    • 16 day UI video tutorial to get you started

      48569 person learning

    • PS Techniques and Slicing Techniques Video Tutorial

      18603 person learning

    Class Library Classification
    HTTP | TCP/IP | basic programming
    Latest Recommendations
    • Alibaba Cloud Environment Construction and Project Launch Video Tutorial

      40936 person learning

    • Overview of Computer Networks - Basic Knowledge that Programmers Must Master

      1549 person learning

    • Essential Tutorial for Programmers - HTTP Protocol Explanation

      1183 person learning

    • Websocket Video Tutorial

      32909 person learning

    Change background image opacity while preserving visibility of child elements
    P粉354602955
    P粉354602955 2023-10-10 19:40:19
    0
    1
    556

    Is it possible to set the opacity of a background image without affecting the opacity of child elements?

    Example

    All links in the footer require custom bullets (background image), and the custom bullets should have an opacity of 50%.

    HTML

    • Link 1
    • Link 2
    • Link 3
    • Link 4
    • Link 5

    CSS

    #footer ul li { background: url(/images/arrow.png) no-repeat 0 50%; }

    What I tried

    I tried setting the list item's opacity to 50%, but the link text's opacity is also 50% - and there doesn't seem to be a way to reset the opacity of the child elements:

    #footer ul li { background: url(/images/arrow.png) no-repeat 0 50%; /* will also set the opacity of the link text */ opacity: 0.5; }

    I also tried using rgba, but that didn't have any effect on the background image:

    #footer ul li { /* rgba doesn't apply to the background image */ background: rgba(255, 255, 255, 0.5) url(/images/arrow.png) no-repeat 0 50%; }


    1
    0
    0
    P粉354602955
    P粉354602955

    reply all (1)
    P粉574268989
    P粉5742689892023-10-11 13:07:40 1 floor

    You can combine CSSlinear-gradient()withrgba().

    div { width: 300px; height: 200px; background: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,.5)), url("https://i.imgur.com/xnh5x47.jpg"); } span { background: black; color: white; }
    Hello world.
    Like+0
    Add Reply 关闭回复
    P粉354602955
      Popular Topics
      More>
      • PHP TutorialPHP Tutorial
      • Laravel TutorialLaravel Tutorial
      • Java TutorialJava Tutorial
      • C# TutorialC# Tutorial
      Popular Articles
      • Ethereum Price Prediction 2024: Will ETH Surpass the $3,000 Threshold?
      • BlockDAG Strikes a $10 Million, 3-Year Deal with European Soccer Titan Borussia Dortmund
      • Black Myth: Wukong How to get licorice seeds
      • 'Black Myth Wukong' Golden Armor Rhino Strategy Guide
      • Should you pry or comfort in Star Wars Outlaws?
      Popular Tutorials
      More>
      Related Tutorials
      Popular Recommendations
      Latest courses
      • The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)
        The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)
        1397801
      • PHP introductory tutorial one: Learn PHP in one week
        PHP introductory tutorial one: Learn PHP in one week
        4211633
      • JAVA Beginner's Video Tutorial
        JAVA Beginner's Video Tutorial
        2373043
      • The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)
        The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)
        1397801
      • JAVA Beginner's Video Tutorial
        JAVA Beginner's Video Tutorial
        2373043
      • Little Turtle's zero-based introduction to learning Python video tutorial
        Little Turtle's zero-based introduction to learning Python video tutorial
        494813
      • Quick introduction to web front-end development
        Quick introduction to web front-end development
        213727
      • Master PS video tutorials from scratch
        Master PS video tutorials from scratch
        847923
      • [Web front-end] Node.js quick start
        [Web front-end] Node.js quick start
        3675
      • Complete collection of foreign web development full-stack courses
        Complete collection of foreign web development full-stack courses
        2815
      • Go language practical GraphQL
        Go language practical GraphQL
        2300
      • 550W fan master learns JavaScript from scratch step by step
        550W fan master learns JavaScript from scratch step by step
        492
      • Python master Mosh, a beginner with zero basic knowledge can get started in 6 hours
        Python master Mosh, a beginner with zero basic knowledge can get started in 6 hours
        12624
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      • [form button] jQuery enterprise message form contact code
      • [Player special effects] HTML5 MP3 music box playback effects
      • [Menu navigation] HTML5 cool particle animation navigation menu special effects
      • [form button] jQuery visual form drag and drop editing code
      • [Player special effects] VUE.JS imitation Kugou music player code
      • [html5 special effects] Classic html5 pushing box game
      • [Picture special effects] jQuery scrolling to add or reduce image effects
      • [Photo album effects] CSS3 personal album cover hover zoom effect
      • [Bootstrap template] Organic fruit and vegetable supplier web template Bootstrap5
      • [backend template] Bootstrap3 multifunctional data information background management responsive web page template-Novus
      • [Bootstrap template] Real estate resource service platform web page template Bootstrap5
      • [Bootstrap template] Simple resume information web template Bootstrap4
      • [Bootstrap template] bootstrap responsive widescreen book education website template-DREAMLIFE
      • [backend template] MAC style responsive blue enterprise CMS background management system template
      • [backend template] Responsive gradient atmosphere background management system website template-usinessbox
      • [Bootstrap template] Responsive vegetable and fruit store website template-Organio
      • [PNG material] Cute summer elements vector material (EPS PNG)
      • [PNG material] Four red 2023 graduation badges vector material (AI EPS PNG)
      • [banner picture] Singing bird and cart filled with flowers design spring banner vector material (AI EPS)
      • [PNG material] Golden graduation cap vector material (EPS PNG)
      • [PNG material] Black and white style mountain icon vector material (EPS PNG)
      • [PNG material] Superhero silhouette vector material (EPS PNG) with different color cloaks and different poses
      • [banner picture] Flat style Arbor Day banner vector material (AI+EPS)
      • [PNG material] Nine comic-style exploding chat bubbles vector material (EPS+PNG)
      • [Front-end template] Home Decor Cleaning and Repair Service Company Website Template
      • [Front-end template] Fresh color personal resume guide page template
      • [Front-end template] Designer Creative Job Resume Web Template
      • [Front-end template] Modern engineering construction company website template
      • [Front-end template] Responsive HTML5 template for educational service institutions
      • [Front-end template] Online e-book store mall website template
      • [Front-end template] IT technology solves Internet company website template
      • [Front-end template] Purple style foreign exchange trading service website template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!