Solved

Can't transition :target, what's wrong with my code?

Posted on 2014-11-10
3
92 Views
Last Modified: 2014-11-13
I'm just trying to create a sample of transitioning :target. The targeting works, but the transition isn't. Can somebody please tell me why? Thanks.

<!DOCTYPE html>
<html>
<head>
<style>
#news1 {
	background-color: white;
	-webkit-transition: background-color, 2s, ease, .1s;
	-moz-transition: background-color, 2s, ease, .1s;
	-o-transition: background-color, 2s, ease, .1s;
	-ms-transition: background-color, 2s, ease, .1s;
	transition: background-color, 2s, ease, .1s;
}
#news2 {
	background-color: white;
	-webkit-transition: background-color, 2s, ease, .1s;
	-moz-transition: background-color, 2s, ease, .1s;
	-o-transition: background-color, 2s, ease, .1s;
	-ms-transition: background-color, 2s, ease, .1s;
	transition: background-color, 2s, ease, .1s;
}
#news1:target {
	border: 2px solid #FF0000;
	background-color: #e5eecc;
}
#news2:target {
	border: 2px solid #FF0000;
	background-color: #e5eecc;
}
</style>
</head>
<body>

<h1>This is a heading</h1>

<p><a href="#news1">Jump to New content 1</a></p>
<p><a href="#news2">Jump to New content 2</a></p>

<p>Click on the links above and the :target selector highlight the current active HTML anchor.</p>

<p id="news1"><b>New content 1...</b></p>
<p id="news2"><b>New content 2...</b></p>

</body>
</html>

Open in new window

0
Comment
Question by:elepil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:elepil
ID: 40440207
Just in case anyone's wondering why I think this isn't working, when clicking one of the links, the target is supposed to transition in background color, i.e., the background color should change gradually, not abruptly, and I don't know why the transition is not working. Thanks.
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 40440345
Remove the commas from your transition declarations.
#news1 {
	background-color: white;
	-webkit-transition: background-color 2s ease .1s;
	-moz-transition: background-color 2s ease .1s;
	-o-transition: background-color 2s ease .1s;
	-ms-transition: background-color 2s ease .1s;
	transition: background-color 2s ease .1s;
}
#news2 {
	background-color: white;
	-webkit-transition: background-color 2s ease .1s;
	-moz-transition: background-color 2s ease .1s;
	-o-transition: background-color 2s ease .1s;
	-ms-transition: background-color 2s ease .1s;
	transition: background-color 2s ease .1s;
}

Open in new window

0
 

Author Closing Comment

by:elepil
ID: 40440357
Oh good grief, I must've been really tired when I did this. Thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question