Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6936381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:13:37+00:00 2026-05-27T12:13:37+00:00

I am trying to get my div to fade out using pure CSS. But

  • 0

I am trying to get my div to fade out using pure CSS. But its not doing anthing, the opacity is not changing?

What is wrong with my code?

<html>
<head>
    <style type="text/css">
    body {
        background-color: red;
    }

    #box{
       width: 300px;
       height: 300px;
       background-color: green;
       -moz-box-shadow: 0px 0px 5px 5px #cc6600;
       -webkit-box-shadow: 0px 0px 5px 5px #cc6600;
       -webkit-transition: opacity 5s;
       -webkit-transform: opacity: 0;
       -webkit-transition-delay: 1s;
       -moz-transition: opacity 5s;
       -moz-transform: opacity: 0;
       -moz-transition-delay: 1s;
    }
    </style>
</head>
<body>

<div id="box">
 Insert your content in here...
</div>


</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:13:38+00:00Added an answer on May 27, 2026 at 12:13 pm

    These lines are invalid syntax:

    -webkit-transform: opacity: 0;
    -moz-transform: opacity: 0;
    

    Opacity is not something that can be used with “transform”. See here for a description of how transform can be used. Further, transform is not what you need here to have an opacity transition where your object fades out.

    In addition, CSS3 transitions are triggered when an object exists in one state and then a second state is applied to it (often by adding a class to the object). This second state specifies a different set of CSS rules and the object can then “transition” from the first state to the second state according to your transition settings.

    You have just specified one state for your object in the #box CSS rules. If you want a transition, then you have to specify a second state and some event that triggers applying the second state.

    For example, this CSS would fade out the box when the mouse hovered over it:

    #box{
       width: 300px;
       height: 300px;
       background-color: green;
       -moz-box-shadow: 0px 0px 5px 5px #cc6600;
       -webkit-box-shadow: 0px 0px 5px 5px #cc6600;
    
       -webkit-transition: opacity 3s;
       -moz-transition: opacity 3s;
    }
    
    #box:hover {
        opacity: 0;
    }
    

    Working demonstration here of both a transition triggered by mouse hover and a transition triggered from adding a class via a button click: http://jsfiddle.net/jfriend00/ZWG5Y/.

    In this demo, we have a starting state and we specify some transition parameters. Then, in the second state (which is triggered by mouse hover here), we specify a second state that the object will transition to when the second state is applied.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a div to fade in using jquery, when the mouse
I'm trying to get both a fadeIn (opacity toggle) and border fade (using jquery-animate-colors
Im trying to get a Gutter Width of 10px between my Div's, but it
I'm trying to get the width of a div container to set another css
I'm trying to work out how to get a div (#tips) to appear when
I am trying to make the top div fade out when it is clicked,
I am trying to get an image to fade out when there has been
I'm trying to get a hidden div to display relative position (directly to the
I'm trying to get: document.createElement('div') //=> true {tagName: 'foobar something'} //=> false In my
I am trying to get a list of values within a div that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.