Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1 class='title'>More / less links example</h1>
<p class="text">Cake dessert sweet oat cake marzipan. Pie cupcake marshmallow dragée caramels icing gummi bears lemon drops jelly. Gingerbread topping chupa chups cake cheesecake pudding gummies. Lollipop dessert bear claw. Topping ice cream soufflé lollipop pudding jelly-o. Sweet jelly cotton candy tiramisu cotton candy. Candy jujubes cookie macaroon caramels topping liquorice. Tiramisu cookie cake halvah chocolate bar candy canes lemon drops icing pie. Cake cake marshmallow bear claw gummi bears cupcake. Ice cream lemon drops lemon drops cookie fruitcake chocolate cheesecake lemon drops powder. Tootsie roll gummi bears gummi bears lemon drops gummies sweet roll brownie toffee cake. Lollipop topping ice cream gummies apple pie chupa chups soufflé candy.</p>
<p class="text">Powder lemon drops cake gingerbread marshmallow cake lemon drops. Tootsie roll apple pie sesame snaps toffee. Tootsie roll cheesecake macaroon tootsie roll. Liquorice jelly gummi bears ice cream. Gummi bears tart marshmallow pastry danish biscuit marzipan marshmallow. Dragée pie bonbon croissant lemon drops gummies biscuit chocolate cake muffin. Jelly carrot cake gummies gummi bears biscuit jujubes jelly beans bonbon tiramisu. Cheesecake chocolate bar cookie lemon drops. Cheesecake bear claw macaroon pastry macaroon jelly-o pie. Cheesecake gummi bears gummies. Jelly dessert pudding jelly wafer candy cupcake. Jelly beans sweet roll toffee apple pie candy. Jelly cake gummies cookie pudding topping. Croissant candy canes chocolate chocolate chupa chups croissant cheesecake pie chocolate cake.</p>

              
            
!

CSS

              
                .title 
	text-align: center
	color: #C2A878
.text
	padding: 10px
	font-size: 18px
	color: #14281D

.ellipsis
	color: #14281D
.more, .less
	color: #355834
	text-decoration: none
	font-weight: bold
	padding: 0 5px
.fa
	margin: 0 5px
	
              
            
!

JS

              
                function moreLess(initiallyVisibleCharacters) {
	var visibleCharacters = initiallyVisibleCharacters;
	var paragraph = $(".text")
	

	paragraph.each(function() {
		var text = $(this).text();
		var wholeText = text.slice(0, visibleCharacters) + "<span class='ellipsis'>... </span><a href='#' class='more'>MORE<i class='fa fa-arrow-circle-o-down' aria-hidden='true'></i></a>" + "<span style='display:none'>" + text.slice(visibleCharacters, text.length) + "<a href='#' class='less'> LESS<i class='fa fa-arrow-circle-o-up' aria-hidden='true'></i></a></span>"
		
		if (text.length < visibleCharacters) {
			return
		} else {
			$(this).html(wholeText)
		}
	});
	$(".more").click(function(e) {
		e.preventDefault();
		$(this).hide().prev().hide();
		$(this).next().show();
	});
	$(".less").click(function(e) {
		e.preventDefault();
		$(this).parent().hide().prev().show().prev().show();
	});
};

moreLess(300);
              
            
!
999px

Console