RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.63% (6.88%*) • Investment PI: 5.49% (6.32%*)

Scrollable Content in WordPress Without an iFrame

Scrollable Content in WordPress Without an iFrame

The overflow CSS shorthand property sets the desired behavior for an element's overflow — i.e. when an element's content is too big to fit in its block formatting context. The CSS overflow property comes in four flavours: visible, hidden, scroll, and auto. In this article we'll show you how to include a scrollable content area without the use of an iframe (using the overflow property). Below the article you'll find a download link to a WordPress shortcode that'll quickly enable the feature on your website.

The Result

The result of our super-simple effort is shown below. shortcode used was [scrollable]Content in here...[/scrollable]

[scrollables]Lorem ipsum auctor sagittis a sum sed sagittis purus sed tincidunt massa massa erat amet elit blandit consectetur facilisis blandit a eros condimentum velit velit hac orci nam eros egestas lorem ipsum accumsan aenean litora eros dui tellus quis habitasse dui rhoncus habitasse torquent eget id etiam mollis ut et ante mattis venenatis nec nisi velit odio mollis curabitur magna scelerisque lorem consectetur vehicula nam id sagittis curabitur auctor justo.

Fringilla at platea praesent aliquet adipiscing sodales pretium platea ornare aenean venenatis leo mollis erat ante nibh gravida in nec eros posuere vestibulum felis fringilla orci consectetur suspendisse magna lacus auctor egestas habitasse nostra amet sapien platea nam sagittis lacinia tellus litora feugiat odio adipiscing tortor placerat eleifend internoetics turpis magna hendrerit eleifend gravida venenatis inceptos inceptos luctus sodales ultricies eget vestibulum nunc magna blandit sed faucibus suspendisse dui conubia orci fusce posuere donec aenean dictum ultrices accumsan posuere eget.[/scrollables]

A number of stylistic and functional attributes apply: margin, padding, height, width, min_height, and style. If we were to apply internal padding and create a small margin, we'd use the following: [scrollable style="border: 3px dotted #000000;" padding="20" height="250"]Content in here...[/scrollable].

[scrollables margin="25" style="border: 3px dotted #000000;" padding="20" height="250"]Fringilla at platea praesent aliquet adipiscing sodales pretium platea ornare aenean venenatis leo mollis erat ante nibh gravida in nec eros posuere vestibulum felis fringilla orci consectetur suspendisse magna lacus auctor egestas habitasse nostra amet sapien platea nam sagittis lacinia tellus litora feugiat odio adipiscing tortor placerat eleifend internoetics turpis magna hendrerit eleifend gravida venenatis inceptos inceptos luctus sodales ultricies eget vestibulum nunc magna blandit sed faucibus suspendisse dui conubia orci fusce posuere donec aenean dictum ultrices accumsan posuere eget.

Fringilla at platea praesent aliquet adipiscing sodales pretium platea ornare aenean venenatis leo mollis erat ante nibh gravida in nec eros posuere vestibulum felis fringilla orci consectetur suspendisse magna lacus auctor egestas habitasse nostra amet sapien platea nam sagittis lacinia tellus litora feugiat odio adipiscing tortor placerat eleifend internoetics turpis magna hendrerit eleifend gravida venenatis inceptos inceptos luctus sodales ultricies eget vestibulum nunc magna blandit sed faucibus suspendisse dui conubia orci fusce posuere donec aenean dictum ultrices accumsan posuere eget.[/scrollables]

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

1
<?php 
2
/*
3
 Scrollable shortcode
4
 https://www.beliefmedia.com.au/scrollable-content-wordpress
5
*/
6
 
7
function beliefmedia_scrollable_shortcode($atts, $content = null) {
8
 
9
 $atts = shortcode_atts(array(
10
 
11
  'margin' => '30',
12
  'padding' => '4',
13
  'height' => '150',
14
  'width' => '100',
15
  'min_height' => '30',
16
  'style' => false
17
 
18
 ), $atts);
19
 
20
 /* If 100 we'll set to 100%, otherwise pixels apply */
21
 $width = ($atts['width'] == '100') ? '100%' : $atts['width'] . 'px';
22
 
23
 /* Result */
24
 $r = '<div style="margin-top: ' . $atts['margin'] . 'px; margin-bottom: ' . $atts['margin'] . 'px; padding: ' . $atts['padding'] . 'px; width: ' . $width . '; min-height: ' . $atts['min_height'] . 'px; max-height: ' . $atts['height'] . 'px; overflow-x: hidden; overflow-y: auto; text-align: justify;';
25
 if ($atts['style'] !== false) $r .= $atts['style'];
26
 $r .= '">' . do_shortcode($content) . '</div>';
27
 
28
 return $r;
29
}
30
add_shortcode('scrollable', 'beliefmedia_scrollable_shortcode');

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

You should alter the default values in the download to your liking to avoid using attributes any time the scrollable feature is used.

Download


Title: WordPress Scrollable
Description: Add scrollable sections to WordPress without the use of iframes. Can be styled to your liking.
  Download • Version 0.1, 652.0B, zip, Category: WordPress Shortcodes
;

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  AUS Eastern Standard Time (Virginia)

  Want to have a chat?
 

RELATED READING

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment