HOME | DD

CypherVisor — dA adds new CSS attributes Skinners! Must read!
Published: 2012-07-20 13:34:34 +0000 UTC; Views: 7040; Favourites: 84; Downloads: 0
Redirect to original
Description body div#devskin8071024 .gr-box { max-width:800px; margin:auto; } body div#devskin8071024 .gr-top h2 { color:#2c3635; } body div#devskin8071024 .gr-top h2 a { color:#2c3635; _background:url('https://fc05.deviantart.net/fs70/f/2012/185/7/3/deviousness_award_by_cyphervisor-d55xhkr.jpg') no-repeat; margin-left:-27px; padding-left:31px; _border:1px solid red; } body div#devskin8071024 .gr-top span, body div#devskin8071024 .list, body div#devskin8071024 .bottom, body div#devskin8071024 .gr-top h2 img { display:none; } body div#devskin8071024 .gr-body { background:#d6e883; border-top:0; padding-bottom:0; } body div#devskin8071024 img { margin-bottom:-20px; } body div#devskin8071024 .text { color:#2c3635; max-width:98%; margin:auto; padding-bottom:0; _margin-bottom:-20px; } body div#devskin8071024 a { color:#2c3635; } body div#devskin8071024 .gr2.gb, body div#devskin8071024 .gr3.gb { background:#f1f2ea; } body div#devskin8071024 .text p:before { content:'I am the content generated automatically'; background:orange; } body div#devskin8071024 .text p:after { content:'got it?'; background:blue; color:white; } body div#devskin8071024 .text a:after { content:attr(href); color:red; font-weight:bold; text-decoration:none; } body div#devskin8071024 .text a.clr:after { content:none; } body div#devskin8071024 h1 { counter-increment:index; font-size:18px; color:#a30e5b; } body div#devskin8071024 h1:before { content:'STEP ' counter(index) ': '; } body div#devskin8071024 h3 { counter-increment:subindex; font-size:16px; color:#2447e0; } body div#devskin8071024 h3:before { content:counter(index) '.' counter(subindex) ' '; font-size:16px; color:#2447e0; } body div#devskin8071024 a.awesome:after { content:none; } body div#devskin8071024 a.awesome { color:#900; text-decoration:none; } body div#devskin8071024 a.awesome:hover { color:red; background:white; position:relative; } body div#devskin8071024 a.awesome[title]:hover:after { content:attr(title); padding:4px 8px; color:#fff; position:absolute; left:0; top:100%; white-space:nowrap; z-index:20; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; box-shadow:0px 0px 4px #222; -moz-box-shadow:0px 0px 4px #222; -webkit-box-shadow:0px 0px 4px #222; box-shadow:0px 0px 4px #222; -moz-box-shadow:0px 0px 4px #222; -webkit-box-shadow:0px 0px 4px #222; box-shadow:0px 0px 4px #222; -moz-box-shadow:0px 0px 4px #222; -webkit-box-shadow:0px 0px 4px #222; background:#349eda; }

Okay, as per the latest dA site update found here . CSS coders are now allowed to use 3 more properties to rock their journal skins.

The properties are:

1) content
2) counter-increment
3) counter-reset

~~~~EXPLANATION~~~~



Lets see what can we do with these new fancy stuffs!

What does these attributes do?

1) content--> it is used to insert generated content in your HTML (Journal body for DA). Don't worry, don't worry! I'll tell you what is this "generated" content!

2) counter-increment --> it is used to insert numbers (or counters) to sections or sub-sections. I'll explain what "sections" and "sub-sections" are don't worry again!

3) counter-reset --> it is used to reset the counters

All these 3 properties are generally interlinked and are used together. But the "content" property can be used alone and has some cool usage.

~~~~"content" property~~~~



The content property requires two  pseudo-elements namely :before and :after to use it in the CSS coding.

The content can take different values such as none, normal, counter, attr(attribute), string, url(url) and, open-quote, close-quote, no-open-quote and no-close-quote. In this small demo I shall only use "string" and "attr(attribute)". The rest can be easily found in the internet if you search. (:

~~~~"content" property DEMO with "string" value~~~~


THE CSS:

.text p:before
{
content:"I am the content generated automatically";
background: orange;
}

.text p:after
{
content:"got it?";
background:blue;
color:white;
}

THE JOURNAL BODY:

by the CSS at the backend!



THE RESULT:

by the CSS at the backend!




Here, the :before and :after pseudo-elements used with the paragraph tag

is generating the content "I am the content generated automatically" and "got it?" automatically as defined in the CSS. Thus, on the usage of

tag in the journal body the pseudo-elements is generating the content at the beginning and end of

tag.

So, the :before selector inserts content before the content of the selected element(s) and :after selector inserts after the element(s).

~~~~"content" property DEMO with "attr(attribute)" value~~~~



THE CSS:

.text a:after
{
content:attr(href);
color:red;
font-weight:bold;
}

THE JOURNAL BODY:

URL of the hyperlink --->


THE RESULT:

URL of the hyperlink --->



Here, content:attr(href) in the CSS is taking the href (which is the URL address) value of the tag.

~~~~"counter-increment" and "counter-reset"property DEMO~~~~



THE CSS:
h1
{
counter-increment:index;
font-size:18px;
color:
#a30e5b ;
}
h1:before
{
content:"STEP " counter(index) ": ";
}
h3
{
counter-increment:subindex;
font-size:16px;
color:#2447e0 ;
}
h3:before
{
content:counter(index) "." counter(subindex) " ";
font-size:16px;
color:#2447e0 ;
}

THE JOURNAL BODY:

Index


Subindex


Subindex



Index


Subindex


Subindex





THE RESULT:
Index
Subindex
Subindex

Index
Subindex
Subindex


How, does the counter-increment work?
Simple! For an element you need to assign a counter first to do this type
counter-increment:subindex;

Here, "subindex" is the name of the counter. See in the CSS above I've use two counters namely "index" and "subindex" for the

tag and

tag Thus, they are both working simultaneously. I've also modified the content generated using strings such as "STEP", "." etc. to get a custom display of the result.

The counter-reset can be used to reset the counter using the syntax below...
counter-reset:COUNTERNAME NUMBER;

The COUNTERNAME is the name of the counter that you want to reset and the NUMBER denotes to which number you want the counter to get reset.

~~~~~~~~~~~~~~~~~



Now, this journal is getting draggy for me and I'm feeling bored to type anymore. So, I'm it ending now. Probably in my next journal I shall show what are the cool stuffs that you can do using these properties. There are much more that you can actually do with these rather than just incrementing numbers and getting simple strings generated using the content property.


CHECK THE CODES BELOW and SEE WHAT YOU CAN POSSIBLY DO!!

~~~~~~~~AWESOME HYPERLINK EFFECT~~~~~~~~~



THE CSS:
a
{
  color: #900;
  text-decoration: none;
}

a:hover
{
  color: red;
  background:white;
  position: relative;
}

a[title]:hover:after
{
  content: attr(title);
  padding: 4px 8px;
  color: #fff ;
  position: absolute;
  left: 0;
  top: 100%;
  white-space: nowrap;
  z-index: 20px;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;  
  border-radius: 5px;  
  -moz-box-shadow: 0px 0px 3px #333;  
  -webkit-box-shadow: 0px 0px 3px #333;  
  box-shadow: 0px 0px 4px #222;  
  background:#349eda ;
}

THE JOURNAL BODY:
CSS-Tricks

Put your mouse over the link below
CSS-Tricks



Keep rocking fellas!!
Sid

Related content
Comments: 120

CypherVisor In reply to ??? [2013-05-25 05:01:59 +0000 UTC]

Just use display:none in the a[title]:hover:after class,

👍: 0 ⏩: 2

gillianivyart In reply to CypherVisor [2013-05-25 10:31:46 +0000 UTC]

Nope, that didn't do it, that hides the after content, I want to keep my after but hide the pop up tooltip. I found a JS to do this, but cannot finds a satisfactory way to do this as a CSS only code.

$('a[title]').qtip({
show: false
});

Here's the journal I am working on [link] Scroll down towards the middle, you will see examples of ACRONYM and Abbreviation. When you hover them, the styled after appears using the title attribute. But then, a second later, the default tooltip appears. Which is browser based, you cannot code it or anything. There is a fake out that you don't use the title attribute, instead you use alt, but that is not available on abbreviation and acronym. There was another fake where you put a span container inside, but that is excessive code for the user to need to input. Why do abbreviation only to enclose a span to hold the pop up? That would be pointless.

Any other ideas? Or is it a no go on dA? The commission didn't request it or anything, I was just trying to see if I could remove it.

👍: 0 ⏩: 1

CypherVisor In reply to gillianivyart [2013-05-26 09:05:11 +0000 UTC]

I understand now. You want to disable the browser tooltip. Well, I have tried it myself to see if I can find a workaround to do that using CSS only. However, I don't see that to be possible without the help of js. JS is required along with CSS to achieve that. CSS alone can't do it.

And yes you can fake out with alt attribute but as you said that doesn't apply to acronym and abbr

nesting span tag is another way but yeah it is a long stuff.

So ultimately, you can't hide the tooltip using CSS alone.

👍: 0 ⏩: 1

gillianivyart In reply to CypherVisor [2013-05-26 09:25:26 +0000 UTC]

Okay, thanks for helping me brain storm it. ;D

👍: 0 ⏩: 1

CypherVisor In reply to gillianivyart [2013-05-26 11:37:14 +0000 UTC]

Most welcome!

👍: 0 ⏩: 0

gillianivyart In reply to CypherVisor [2013-05-25 08:39:31 +0000 UTC]

to hide the default one? Okies. It will still let me do the styled replacement one though, right.... Okay, I think I see how that works there. Thanks!

👍: 0 ⏩: 0

Seranda7 [2012-08-04 16:19:22 +0000 UTC]

That's awesome, I wanted to use this just a few days ago!

👍: 0 ⏩: 1

CypherVisor In reply to Seranda7 [2012-08-06 05:35:32 +0000 UTC]

I see!

👍: 0 ⏩: 0

EternalStay [2012-07-29 11:07:06 +0000 UTC]

I think you misspelled Skinner

👍: 0 ⏩: 1

CypherVisor In reply to EternalStay [2012-07-29 12:08:27 +0000 UTC]

Well, actually not. I had reached the total number of characters that can be entered for the journal title so I had to reduce one "n" in the skinner. But at that time I had written CSS3 which now I've replaced with just CSS so I guess I can put an "n" in the skinner! *Goes to edit the title again...*

👍: 0 ⏩: 1

EternalStay In reply to CypherVisor [2012-07-29 12:15:21 +0000 UTC]

Content is a CSS 2.1 attribute anyway
[link]

👍: 0 ⏩: 1

CypherVisor In reply to EternalStay [2012-07-29 12:21:04 +0000 UTC]

Well, I know that too. You may read some comments that I got earlier mentioning about the same. But to grab people's attention I had put it to be as CSS3 intentionally. I had removed it after a while and made it as "CSS" as you can see now.

👍: 0 ⏩: 1

EternalStay In reply to CypherVisor [2012-07-29 12:33:17 +0000 UTC]

Oh sorry, I normally read other comments first

👍: 0 ⏩: 1

CypherVisor In reply to EternalStay [2012-07-29 12:42:29 +0000 UTC]

Haha.. that's okay...

👍: 0 ⏩: 0

pixiepot [2012-07-29 07:41:36 +0000 UTC]

Thank you for this, it will be very useful for future references.
May I also ask for an example for in what realistic instance would content be used in? Thank you.

👍: 0 ⏩: 1

CypherVisor In reply to pixiepot [2012-07-29 12:11:51 +0000 UTC]

You're welcome dear. Umm... you can use content in many instances like having a pop-up button title, Image name highlighting over it or perhaps adding an image on hyperlinks at the end or beginning!

👍: 0 ⏩: 1

pixiepot In reply to CypherVisor [2012-07-29 12:26:05 +0000 UTC]



Thank you! I'll try to use these elements in my next skin, I suppose. Also, thanks for the prompt reply.

👍: 0 ⏩: 1

CypherVisor In reply to pixiepot [2012-07-29 12:42:55 +0000 UTC]

No problem!

And I shall be glad to see them!

👍: 0 ⏩: 1

pixiepot In reply to CypherVisor [2012-07-29 12:48:55 +0000 UTC]



Thank you!

👍: 0 ⏩: 0

firstfear [2012-07-28 17:26:45 +0000 UTC]

thank you for this!

👍: 0 ⏩: 1

CypherVisor In reply to firstfear [2012-07-29 12:12:01 +0000 UTC]

You're welcome dear!

👍: 0 ⏩: 0

SingingFlames [2012-07-28 15:24:01 +0000 UTC]

Oh, neat! I'm still learning all this, but this is good to know.

👍: 0 ⏩: 1

CypherVisor In reply to SingingFlames [2012-07-28 16:11:53 +0000 UTC]

That's great. And thanks..

👍: 0 ⏩: 0

AsjJohnson [2012-07-26 12:20:47 +0000 UTC]

Can I use the :before one to put a :icon : code in front of something? If so, can you show me how?
Or can I put something like, another paragraph within the :before thing? Like, :before {

}
...though, it looks like it's not possible to use that property that way...

👍: 0 ⏩: 1

CypherVisor In reply to AsjJohnson [2012-07-26 14:44:08 +0000 UTC]

Well, you can surely use string to generate content using the :before pseudo-element so I think you can have a paragraph generated using it. But I'm not sure how long the string can be to be used.

I don't know whether it is possible to generate the :iconUSERNAME: code. But it would be awesome though! You've given a nice perspective here. I can give a try to see if that's possible!

👍: 0 ⏩: 1

AsjJohnson In reply to CypherVisor [2012-07-26 14:53:09 +0000 UTC]

I mainly wondered because I tried making the default journal skin, and when I pushed the mini-avatar in front of the date, it messed up the bottom of the journal. So if I could use the content thing to put the avatar there, it would probably work better.

👍: 0 ⏩: 1

CypherVisor In reply to AsjJohnson [2012-07-27 05:23:45 +0000 UTC]

Hmm... Okay!

👍: 0 ⏩: 0

Chivi-chivik [2012-07-22 10:57:13 +0000 UTC]

Cool, but this is CSS2, for you to know

👍: 0 ⏩: 1

CypherVisor In reply to Chivi-chivik [2012-07-22 19:22:16 +0000 UTC]

Yes, actually I know its CSS2. I have mentioned it as CSS3 so people gets an interest to view it as something new in the dA CSS you know. May be I'll change it to CSS2.

But, it's great that you've mentioned it after noticing!

👍: 0 ⏩: 1

Chivi-chivik In reply to CypherVisor [2012-07-22 19:26:17 +0000 UTC]

Now I understand!
But I'd have been interested anyways (this in my case) because DA still has many CSS limits than other webpages.

not at all

👍: 0 ⏩: 1

CypherVisor In reply to Chivi-chivik [2012-07-22 19:39:07 +0000 UTC]

Its better to limit some of this properties I would say otherwise too much customization can make DA dirty.

👍: 0 ⏩: 1

Chivi-chivik In reply to CypherVisor [2012-07-22 19:53:21 +0000 UTC]

Yes, but there are others that could be awesome. (as the 'border-radius' one)

👍: 0 ⏩: 1

CypherVisor In reply to Chivi-chivik [2012-07-22 19:58:37 +0000 UTC]

border-radius does work in dA. And I use it often in my skins..

👍: 0 ⏩: 1

Chivi-chivik In reply to CypherVisor [2012-07-22 21:20:21 +0000 UTC]

seriously? It told me that it didn't work!

👍: 0 ⏩: 1

CypherVisor In reply to Chivi-chivik [2012-07-23 11:09:57 +0000 UTC]

Huh! It works fine.

👍: 0 ⏩: 1

Chivi-chivik In reply to CypherVisor [2012-07-23 17:40:14 +0000 UTC]

What I have to write then?
I know that Mozilla and Safari need to introduce the "mozilla-border-radius" and "webkit-border-radius" for it to work. ("border-radius" itself only works in Opera).

👍: 0 ⏩: 1

CypherVisor In reply to Chivi-chivik [2012-07-23 18:15:32 +0000 UTC]

just border-radius works with all the browsers provided you've all updated version of them all.

👍: 0 ⏩: 1

Chivi-chivik In reply to CypherVisor [2012-07-23 18:22:14 +0000 UTC]

So I have to write "border-radius" and that'll be enough?

👍: 0 ⏩: 1

CypherVisor In reply to Chivi-chivik [2012-07-23 18:47:37 +0000 UTC]

Yes!

But I'd recommend to use all the cross-browser compatible CSS properties!

👍: 0 ⏩: 1

Chivi-chivik In reply to CypherVisor [2012-07-23 19:43:53 +0000 UTC]

Cross-browser? Explain me about that please

👍: 0 ⏩: 1

CypherVisor In reply to Chivi-chivik [2012-07-24 15:05:52 +0000 UTC]

Umm, sometimes a property doesn't work with other browsers such as if a property is compatible with firefox it may not be compatible with Chrome or IE. So, you need to use cross-browser compatible properties for example... if you use "border-radius" its better to use the following together.

border-radius: 10px; /* CSS3 */
-moz-border-radius: 10px; /* Firefox */
-webkit-border-radius: 10px; /* Safari, Chrome */

👍: 0 ⏩: 1

Chivi-chivik In reply to CypherVisor [2012-07-24 17:18:04 +0000 UTC]

I had the feeling that that was that... thanks

Well I'll try the next time I make a journal skin.

Thanks again

👍: 0 ⏩: 1

CypherVisor In reply to Chivi-chivik [2012-07-25 05:54:37 +0000 UTC]

Sure thing mate! And np!

👍: 0 ⏩: 1

Chivi-chivik In reply to CypherVisor [2012-07-25 10:29:02 +0000 UTC]

👍: 0 ⏩: 0

archaemic [2012-07-22 09:37:17 +0000 UTC]

These are all CSS2 ...

👍: 0 ⏩: 1

CypherVisor In reply to archaemic [2012-07-22 19:22:11 +0000 UTC]

Yes, actually I know its CSS2. I have mentioned it as CSS3 so people gets an interest to view it as something new in the dA CSS you know. May be I'll change it to CSS2.

But, it's great that you've mentioned it after noticing!

👍: 0 ⏩: 0

dynamicability [2012-07-22 08:30:56 +0000 UTC]

awesome... I need to try

but I'll will try if I have a premium membership

👍: 0 ⏩: 1

CypherVisor In reply to dynamicability [2012-07-22 19:18:52 +0000 UTC]

You can try it in your stash writer I suppose!

Though you might not be able to use it.

👍: 0 ⏩: 0

daremaker [2012-07-22 03:01:33 +0000 UTC]

I seriously need to learn some coding @.@

👍: 0 ⏩: 1

CypherVisor In reply to daremaker [2012-07-22 19:18:13 +0000 UTC]

Haha...Sure thing! Go ahead!

👍: 0 ⏩: 0


| Next =>