HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!-- JJ -->
<div id="contentBoxApp" ng-app="contentBoxApp">
<div id="GridCtrl" ng-controller="GridCtrl">
<div class="toolbar">
<div class="container">
<div class="toolbar-section">
<span class="logo toolbar-item"><i class="fa fa-picture-o"></i>ContentGrid</span>
</div><!-- /.toolbar-section -->
<div class="toolbar-section">
<div class="toolbar-item form-field">
<input type="text" name="filter" placeholder="phrase to filter" ng-model="search"/>
</div>
</div><!-- /.toolbar-section -->
</div><!-- /.container -->
</div><!-- /.toolbar -->
<div class="container dynamic-grid">
<article class="grid-item content-box" ng-repeat="(gridKey, gridItem) in gridItems | filter:filterBySearch">
<div class="inner">
<img class="content-box-thumb"src="{{ gridItem.img }}" alt="tech image" />
<h1 class="content-box-header">
{{ gridItem.headerText }}
</h1>
<p class="content-box-blurb">
{{ gridItem.blurbText }}
</p>
<a class="readmore-link" href="#" ng-click="toggleBlurb($event)">read more</a>
</div>
</article><!-- /.content-box -->
</div><!-- /.dynamic-grid -->
</div><!-- /#GridCtrl -->
</div><!-- /#contentBoxApp -->
<!-- SDG -->
$bg: rgba(255,255,255, 1);
$fg: rgba(58,58,58, 1);
$linkColor: #0074D9;
$border: 0px solid rgba(230,230,230,1);
$margin: 1rem;
$padding: 1rem 1rem 1rem 1rem;
$lineHeight: 1.4rem;
$boxShadowColor: rgba(58,58,58,0.1);
$boxShadow: 0px -1px 2px $boxShadowColor, 1px 1px 2px $boxShadowColor;
$gradient: linear-gradient(rgba(0,0,0,0.07), rgba(255,255,255,0));
$navFg: rgba(255,255,255, 1);
$navBg: rgba(58,58,58, 0.95);
$navBg: rgba(25,47,66, 0.95);
body * {
font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
line-height: $lineHeight;
}
body {
background: #efefef;
color: $fg;
&:before {
content: '';
display: block;
position: fixed;
z-index: 0;
height: 100%;
width: 100%;
max-height: 100vh;
max-width: 100wh;
top: 0px;
left: 0px;
box-shadow: inset 0px 0px 50px rgba(0,0,0,0.55);
}
}
a {
color: $linkColor;
text-decoration: none;
font-size: 0.85rem;
opacity: 0.75;
linear-gradient: ease-in-out 0.6s;
&:hover {
linear-gradient: ease-in-out 0.6s;
opacity: 1;
}
}
.container {
width: 90%;
max-width: 1280px;
margin: 0px auto;
}
.toolbar {
position: fixed;
z-index: 2;
width: 100%;
height: 3.75rem;
padding: 0px;
vertical-align: middle;
overflow: hidden;
background: $navBg;
color: $navFg;
box-shadow: 0px 0px 25px rgba(0,0,0,0.25);
}
.toolbar-section {
position: relative;
display: inline-block;
vertical-align: middle;
&:first-child {
width: 60%;
}
&:last-child {
width: 35%;
}
@media (max-width: 480px) {
display: block;
&:last-child {
display: none;
}
}
}
.toolbar-item {
display: block;
padding: $padding;
white-space: nowrap;
}
.form-field {
text-align: right;
input {
font-size: 1rem;
line-height:1.4rem;
height: 1.4rem;
max-width: 100%;
display: inline-block;
padding: 4px 7px;
border: 1px solid lighten($navBg, 5%);
background: darken($navBg, 02%);
outline: 0px;
color: lighten($navBg, 50%);
//$placeholderColor: lighten($navBg, 10%);
$placeholderColor: rgba(255,255,255,0.35);
&::-webkit-input-placeholder { color: $placeholderColor; }
&:-moz-placeholder { color: $placeholderColor; }
&::-moz-placeholder { color: $placeholderColor; }
&:-ms-input-placeholder { color: $placeholderColor; }
}
}
.logo {
font-family: "Oswald", Helvetica, Arial, sans-serif;
font-size: 1em;
letter-spacing: 0.15rem;
i { font-size: 1.2em; margin-right: 6px; }
}
.dynamic-grid {
position: relative;
z-index: 1;
columns: 240px 3;
column-gap: 15px;
&.container {
padding-top: 6rem;
}
}
.grid-item {
position: relative;
display: inline-block;
margin: $margin;
max-width: 100%;
column-break-inside: avoid;
.inner {
padding: $padding;
}
}
.content-box {
border: $border;
background-color: $bg;
box-shadow: $boxShadow;
&:before {
content: '';
position: absolute;
display: block;
width: 100%;
height: 4rem;
left: 0px;
top: 0px;
}
}
.content-box-thumb {
display: block;
max-width: 100%;
height: auto;
}
.content-box-header {
font-size: 1rem;
margin: 0.75rem 0rem 0rem 0rem;
}
.content-box-blurb {
font-size: 0.85rem;
display: block;
display: -webkit-box;
margin: 0rem;
max-width: 100%;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.readmore-link {
display: block;
margin: 5px 5px 0px 5px;
text-align: right;
}
var contentBoxApp = angular.module('contentBoxApp', []);
var gridCtrl = contentBoxApp.controller('GridCtrl', function($scope) {
var regex;
$scope.escapeRegExp = function(string){
return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
};
$scope.gridItems = [
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/QrXgXMhCSouyhU7idq7g_IMG_8402.jpg',
headerText: 'Fireworks on the 4th',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil voluptatibus aliquam asperiores, cum distinctio aliquid recusandae velit beatae. Reprehenderit in eum, expedita, alias explicabo iure amet. Assumenda consequuntur vitae fugit.'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/dandelion.jpg',
headerText: 'Dandelion',
blurbText: 'cliff Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae assumenda facilis qui minus, consequuntur reiciendis atque fugiat ullam id, placeat nam quas, voluptates ipsum velit voluptatum culpa numquam saepe quos!'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/C3EWdWzT8imxs0fKeKoC_blackforrest.jpg',
headerText: 'Cabin in the Woods',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Veniam vero cum vitae laboriosam nemo quaerat, sapiente harum reiciendis voluptas itaque incidunt molestias, fugiat asperiores dolores officiis architecto nihil assumenda. Fugiat!'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/unsplash_522b9cc0386f1_1.jpg',
headerText: 'Lazy Sunday',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit, ex minima, fugiat itaque error voluptates inventore sunt sequi possimus tempore odit debitis sint. Repudiandae quia esse totam eum blanditiis sunt?'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/MIbCzcvxQdahamZSNQ26_12082014-IMG_3526.jpg',
headerText: 'Yogi',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque nisi magnam cum nam iusto fugiat suscipit tempora nostrum autem, quasi, nemo illo sunt vitae id consectetur. Culpa reprehenderit esse sapiente?'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/cA4aKEIPQrerBnp1yGHv_IMG_9534-3-2.jpg',
headerText: 'Antique Typewriter',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi, blanditiis autem, ex quidem hic unde dolorum deleniti tenetur repellat nesciunt delectus pariatur voluptate corrupti inventore iure, itaque, fuga natus doloribus.'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/unsplashed2-photo-1428604467652-115d9d71a7f1.jpeg',
headerText: 'The Sun is Setting',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque et amet aspernatur ullam, accusamus cum. Minima obcaecati voluptate velit cupiditate error ut, suscipit saepe beatae eaque veniam. Maiores, reiciendis quo.'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/unsplashed2-photo-1422640805998-18a4dd89bec2.jpeg',
headerText: 'Staring at the Stars',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit ducimus recusandae deleniti nobis unde dolor minus ut corporis saepe tempora architecto, possimus! Obcaecati odit nam vero ipsum odio vel iste.'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/unsplashed2-photo-IPEivX6xSBaiYOukY88V_DSC06462_tonemapped.jpg',
headerText: 'On the Road Again',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Unde, laboriosam impedit expedita alias quod repellendus reiciendis, officiis ullam iste delectus perferendis odio officia, commodi nihil voluptas aliquam. Enim, minus, unde!'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/unsplashed2-photo-1428591501234-1ffcb0d6871f.jpeg',
headerText: 'Just Me, Myself, and I',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia quidem alias libero vel sunt quod non, aspernatur rerum nisi porro corrupti minus unde hic nemo labore veniam! Ipsa, nam, quas!'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/unsplashed2-photo-1427348693976-99e4aca06bb9.jpeg',
headerText: 'Early Morning Hike',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam, sequi, cumque temporibus, mollitia obcaecati earum provident labore adipisci repellendus fugiat repellat quas doloribus incidunt ipsum. Tempore delectus quas illum ex!'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/unsplashed2-photo-1414912925664-0c502cc25dde.jpeg',
headerText: 'Getting Away for the Weekend',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Temporibus voluptate nam provident, nulla recusandae maxime fugit praesentium blanditiis sunt, veniam quasi, mollitia possimus consequuntur nemo qui repellat adipisci accusamus ullam.'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/unsplashed2-photo-1428342319217-5fdaf6d7898e.jpeg',
headerText: 'The Bridge',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit ducimus recusandae deleniti nobis unde dolor minus ut corporis saepe tempora architecto, possimus! Obcaecati odit nam vero ipsum odio vel iste.'
},
{
img: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/6234/unsplashed2-photo-1423483641154-5411ec9c0ddf.jpeg',
headerText: 'Visit to the Vineyard',
blurbText: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit ducimus recusandae deleniti nobis unde dolor minus ut corporis saepe tempora architecto, possimus! Obcaecati odit nam vero ipsum odio vel iste.'
}
];
$scope.search = '';
$scope.$watch('search', function (value) {
regex = new RegExp('\\b' + $scope.escapeRegExp(value), 'i');
});
$scope.filterBySearch = function(gridItem) {
if (!$scope.search) return true;
return regex.test(gridItem.headerText + " " + gridItem.blurbText);
};
$scope.toggleBlurb = function($event) {
console.log($event);
};
});
Also see: Tab Triggers