You are viewing limited content. For full access, please sign in.

Question

Question

Forms - Anyone have code for adding "Expand" and "Collapse" next to the ^ symbols for collapsible sections?

asked on November 8, 2016 Show version history

I've got a client who is asking for the appropriate word to show up next to the image. 

0 0

Answer

SELECTED ANSWER
replied on November 8, 2016

Hi Chris,

Is this something like they'd want? (see attached video)

Custom CSS:

.collapsible h1, .collapsible.collapsed h1 {
  background: transparent;
}
.collapsible h1:after {
  color: red;
  content: 'Collapse';
  display: inline-block;
  float: right;
  font-family: serif;
  font-size: 0.75em;
}
.collapsible.collapsed h1:after {
  color: blue;
  content: 'Expand';
}

Basically the arrow itself is the background image of the .collapsible h1 element. So first we set the background to transparent to remove that. Then you can use the :after pseudoselector to set text content to come appended to the header. Then you can apply formatting, etc.

The element itself has the .collapsible class, but when it is actually collapsed, it has the additional .collapsed class, so you can select .collapsible to set default values and for the expanded state, and select .collapsible.collapsed to set values for the collapsed state.

Hope this helps!

collapsible.swf (385.13 KB)
1 0
replied on November 10, 2016

Thanks for the css code. I implemented it yesterday and it worked great. It makes sense what was happening when I added my own text up there now knowing it was a background image. 

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.