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.
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<div id="root"></div>
</div>
<div class="row">
<div class="col-sm-6 col-md-4 col-lg-3 mt-4">
<div class="card">
<img class="card-img-top" src="https://picsum.photos/200/150/?random
">
<div class="float-right m-1" style="position:absolute;right:0">
<button type="button" class="btn btn-light m-0 text-left" style="border:#444444">
<i class="fas fa-ellipsis-v"></i>
</button>
</div>
<div class="whenhovered">
<div class="float-right mr-0">
<button type="button" class="btn btn-light m-0 text-left">
MORE
<i class="fas fa-ellipsis-v pl-2"></i>
</button>
</div>
<div class="mt-5 pt-5">
<button type="button" class="btn btn-light w-75 m-3 mt-5 text-left">
<i class="fas fa-eye pr-2"></i>
VIEW BOARD
</button>
</div>
<div>
<button type="button" class="btn btn-light w-75 m-3 text-left">
<i class="fas fa-thumbtack pr-2"></i>
PIN
</button>
</div>
<div>
<button type="button" class="btn btn-light w-75 m-3 text-left">
<i class="fas fa-share pr-2"></i>
SHARE
</button>
</div>
</div>
<div class="card-block">
<h4 class="card-title">Title Text</h4>
<div class="meta">
<a href="#">Friends</a>
</div>
<div class="card-text">
Lorem ipsum dolor sit amet, consectetur.
</div>
</div>
<div class="card-footer">
<span class="float-right">Joined in 2013</span>
<span><i class=""></i>75 Friends</span>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3 mt-4">
<div class="card">
<img class="card-img-top" src="https://picsum.photos/200/150/?random">
<div class="card-block">
<h5 class="text-bold">Title Text</h5>
</div>
<CardHoverMenus/>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3 mt-4">
<div class="card">
<img class="card-img-top" src="https://picsum.photos/200/150/?random
">
<p class="card-block">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam velit quisquam veniam excepturi temporibus inventore corporis dicta sit culpa veritatis placeat earum, dolorum asperiores, delectus dolore voluptatibus, at magnam nobis!
</p>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3 mt-4">
<div class="card">
<img class="card-img-top" src="https://picsum.photos/200/150/?random
">
<div class="card-block">
<figure class="profile">
<img src="https://picsum.photos/200/150/?random" class="profile-avatar" alt="">
</figure>
<h4 class="card-title mt-3">Title Text</h4>
<div class="meta">
<a>Friends</a>
</div>
<div class="card-text">
Lorem ipsum dolor sit amet, consectetur.
</div>
</div>
<div class="card-footer">
<small>Last updated 3 mins ago</small>
<button class="btn btn-secondary float-right btn-sm">show</button>
</div>
</div>
</div>
</div>
<div class="row mb-5">
<div class="col-sm-6 col-md-4 col-lg-3 mt-4">
<div class="card card-inverse card-primary ">
<img class="card-img-top" src="https://picsum.photos/200/150/?random">
<blockquote class="card-blockquote p-3">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.</p>
<footer>
<small>
Someone famous in <cite title="Source Title">Source Title</cite>
</small>
</footer>
</blockquote>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3 mt-4">
<div class="card card-inverse card-info">
<img class="card-img-top" src="https://picsum.photos/200/150/?random">
<div class="card-block">
<figure class="profile">
<img src="https://picsum.photos/200/150/?random" class="profile-avatar" alt="">
</figure>
<h4 class="card-title mt-3">Title Text</h4>
<div class="meta card-text">
<a>Friends</a>
</div>
<div class="card-text">
Lorem ipsum dolor sit amet, consectetur.
</div>
</div>
<div class="card-footer">
<small>Last updated 3 mins ago</small>
<button class="btn btn-info float-right btn-sm">Follow</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3 mt-4">
<div class="card card-inverse card-info">
<img class="card-img-top" src="https://picsum.photos/200/150/?random">
<div class="card-block">
<figure class="profile profile-inline">
<img src="https://picsum.photos/200/150/?random" class="profile-avatar" alt="">
</figure>
<h4 class="card-title">Title Text</h4>
<div class="card-text">
Lorem ipsum dolor sit amet, consectetur.
</div>
</div>
<div class="card-footer">
<small>Last updated 3 mins ago</small>
<button class="btn btn-info float-right btn-sm">Follow</button>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3 mt-4">
<div class="card card-inverse card-info">
<img class="card-img-top" src="https://picsum.photos/200/150/?random">
<div class="card-block">
<figure class="profile profile-inline">
<img src="https://picsum.photos/200/150/?random" class="profile-avatar" alt="">
</figure>
<h4 class="card-title">Title Text</h4>
<div class="card-text">
Lorem ipsum dolor sit amet, consectetur.
</div>
</div>
<div class="card-footer">
<button class="btn btn-info btn-sm">Follow</button>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="card-deck">
<div class="card mb-4">
<img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">1 Card title</h4>
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="card mb-4">
<img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">2 Card title</h4>
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="w-100 d-none d-sm-block d-md-none">
<!-- wrap every 2 on sm-->
</div>
<div class="card mb-4">
<img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">3 Card title</h4>
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="w-100 d-none d-md-block d-lg-none">
<!-- wrap every 3 on md-->
</div>
<div class="card mb-4">
<img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">4 Card title</h4>
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="w-100 d-none d-sm-block d-md-none">
<!-- wrap every 2 on sm-->
</div>
<div class="w-100 d-none d-lg-block d-xl-none">
<!-- wrap every 4 on lg-->
</div>
<div class="card mb-4">
<img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">5 Card title</h4>
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="w-100 d-none d-xl-block">
<!-- wrap every 5 on xl-->
</div>
<div class="card mb-4">
<img class="card-img-top img-fluid" src="//placehold.it/500x300" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">6 Card title</h4>
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="w-100 d-none d-sm-block d-md-none">
<!-- wrap every 2 on sm-->
</div>
<div class="w-100 d-none d-md-block d-lg-none">
<!-- wrap every 3 on md-->
</div>
<div class="card mb-4">
<img class="card-img-top img-fluid" src="//placehold.it/500x270" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">7 Card title</h4>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="card mb-4">
<img class="card-img-top img-fluid" src="//placehold.it/500x300" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">8 Card title</h4>
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="w-100 d-none d-sm-block d-md-none">
<!-- wrap every 2 on sm-->
</div>
<div class="w-100 d-none d-lg-block d-xl-none">
<!-- wrap every 4 on lg-->
</div>
<div class="card mb-4">
<img class="card-img-top img-fluid" src="//placehold.it/500x270" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="w-100 d-none d-md-block d-lg-none">
<!-- wrap every 3 on md-->
</div>
<div class="card mb-4">
<img class="card-img-top img-fluid" src="//placehold.it/500x270" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">10 Card title</h4>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.This is a wider card with supporting text below as a natural lead-in
to additional content. This card has even longer content than the first to show that equal height action.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
</div>
</div>
html {
font-family: Lato, 'Helvetica Neue', Arial, Helvetica, sans-serif;
font-size: 14px;
}
h5 {
font-size: 1.28571429em;
font-weight: 700;
line-height: 1.2857em;
margin: 0;
}
.card {
font-size: 1em;
overflow: hidden;
padding: 0;
border: none;
border-radius: .28571429rem;
box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 0 1px #d4d4d5;
}
.card-block {
font-size: 1em;
position: relative;
margin: 0;
padding: 1em;
border: none;
border-top: 1px solid rgba(34, 36, 38, .1);
box-shadow: none;
}
.card-img-top {
display: block;
width: 100%;
height: auto;
}
.card-title {
font-size: 1.28571429em;
font-weight: 700;
line-height: 1.2857em;
}
.card-text {
clear: both;
margin-top: .5em;
color: rgba(0, 0, 0, .68);
}
.card-footer {
font-size: 1em;
position: static;
top: 0;
left: 0;
max-width: 100%;
padding: .75em 1em;
color: rgba(0, 0, 0, .4);
border-top: 1px solid rgba(0, 0, 0, .05) !important;
background: #fff;
}
.card-inverse .btn {
border: 1px solid rgba(0, 0, 0, .05);
}
.profile {
position: absolute;
top: -12px;
display: inline-block;
overflow: hidden;
box-sizing: border-box;
width: 25px;
height: 25px;
margin: 0;
border: 1px solid #fff;
border-radius: 50%;
}
.profile-avatar {
display: block;
width: 100%;
height: 100%;
border-radius: 50%;
}
.profile-inline {
position: relative;
top: 0;
display: inline-block;
}
.profile-inline ~ .card-title {
display: inline-block;
margin-left: 4px;
vertical-align: top;
}
.text-bold {
font-weight: 700;
}
.meta {
font-size: 1em;
color: rgba(0, 0, 0, .4);
}
.meta a {
text-decoration: none;
color: rgba(0, 0, 0, .4);
}
.meta a:hover {
color: rgba(0, 0, 0, .87);
}
.card {
position:relative;
overflow:hidden;
}
.whenhovered {
position:absolute;
top:-100%;
right:0;
background:rgba(0, 0, 0, 0);
width:100%;
height:100%;
padding:2%;
text-align:center;
color:#fff !important;
z-index:2;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.card:hover .whenhovered {
top:0%;
background:rgba(0, 0, 0, 0.75);
}
class CardMoreMenuBtn extends React.Component {
render() {
const p = this.props;
const clsD = (p.isRight) ? "float-right mr-0" : "";
const clsB = (p.isRight) ? " m-0" : " w-100 p-3";
const clsI = (p.isRight) ? " pl-2" : " pr-3 pl-4";
const iconTag = <i className={"fas fa-" + this.props.icon + clsI} />;
return (
<div className={clsD}>
<button type="button"
className={"btn btn-light text-left " + clsB}
onClick={this.props.clicked}>
{p.isRight || <div>{iconTag}{p.txt}</div>}
{p.isRight && <div>{p.txt}{iconTag}</div>}
</button>
</div>
)}
}
class CardMoreMenu extends React.Component {
render = ()=>{
const p = this.props;
return p.hidden ? (
<CardMoreMenuBtn clicked={p.toggle}
isRight={true}
icon="ellipsis-v" txt="MORE"
/>
) : (
<div style={{ background: "white",maxWidth:300,float:"right" }} className="mr-1">
<CardMoreMenuBtn clicked={p.funcs.pinAny}
icon="thumbtack" txt="Pin card to any board"
/>
<CardMoreMenuBtn clicked={p.funcs.pinHere}
icon="thumbs-up" txt="Pin card to this board"
/>
<CardMoreMenuBtn clicked={p.funcs.notInterested}
icon="thumbs-down" txt="Not interested in this card"
/>
<CardMoreMenuBtn clicked={p.funcs.shareCard}
icon="share" txt="Share this card"
/>
<CardMoreMenuBtn clicked={p.funcs.viewBoard}
icon="eye" txt="View board"
/>
</div>
);
}
}
const CardHoverButton = (p)=>{return(
<div>
<button type="button" onClick={p.clicked}
className="btn btn-light w-75 m-3 text-left">
<i className={"fas fa-"+p.icon+" pr-2"}></i>
{p.txt}
</button>
</div>
)}
const evStop = (ev)=>{
ev.preventDefault()
ev.stopPropagation();
ev.nativeEvent.stopImmediatePropagation();
}
class CardHoverMenus extends React.Component {
state = { hiddenPopupMenu: true }
toggle = ()=>{ this.setState({ hiddenPopupMenu: ! this.state.hiddenPopupMenu }); } clkBtn = (ev, msg) => {
evStop(ev);
this.props.flash(msg);
};
render() {
const p = {
funcs: {
viewBoard: e => this.clkBtn(e, "viewBoard"),
pinAny: e => this.clkBtn(e, "pinAny"),
pinHere: e => this.clkBtn(e, "pinHere"),
notInterested: e => this.clkBtn(e, "notInterested"),
shareCard: e => this.clkBtn(e, "shareCard")
}
};
//Above is hardwired for demo. Normally, const p = this.props;
return (
<div className="whenhovered" onClick={this.toggle}>
<CardMoreMenu funcs={p.funcs}
hidden={this.state.hiddenPopupMenu} toggle={this.toggle}/>
{ this.state.hiddenPopupMenu && (
<div>
<div className="mt-5 pt-5"></div>
<div className="mt-5"></div>
<CardHoverButton txt="VIEW BOARD"
icon="eye" clicked={p.funcs.viewBoard}/>
<CardHoverButton txt="PIN"
icon="thumbtack" clicked={p.funcs.pinAny}/>
<CardHoverButton txt="SHARE"
icon="share" clicked={p.funcs.shareCard}/>
</div>)}
</div>
)}
}
class Card extends React.Component {
moreBtn = (
<div className="float-right m-1" style={{position:"absolute",right:0}}>
<button type="button"
className="btn btn-light m-0 text-left"
style={{border:"#444444"}}
>
<i className="fas fa-ellipsis-v" />
</button>
</div>
)
render() { return (
/*<div className="col-sm-6 col-md-4 col-lg-3 mt-4" id={"card"+this.props.id}>*/
<div className="col-sm-6 col-md-6 col-lg-4 mt-4">
<div className="card">
<img
className="card-img-top"
src="https://picsum.photos/200/150/?random"/>
{this.moreBtn}
<CardHoverMenus flash={this.props.flash}/>
<div className="card-block">
<h4 className="card-title">Title Text</h4>
<div className="meta">
<a href="#">Friends</a>
</div>
<div className="card-text">
Lorem ipsum dolor sit amet, consectetur.
</div>
</div>
<div className="card-footer">
<span className="float-right">Joined in 2013</span>
<span>
<i className="" />75 Friends
</span>
</div>
</div>
</div>
)}
}
class Cards extends React.Component{
state={msg:null}
flash=(m)=>{
this.setState({msg:m})
setTimeout(()=>{this.setState({msg:null})},2000)
}
render() { return(
<div>
<h5>{this.state.msg || "_"}</h5>
<div className="row">
{Array(8).fill(42).map( (x,i) => <Card key={i} flash={this.flash}/>) }
</div>
</div>
)}
}
ReactDOM.render(<Cards />, document.getElementById("root"));
Also see: Tab Triggers