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.
<div class="modal-open">モーダルを開く</div>
<div class="modal-container">
<div class="modal-body">
<div class="modal-close">×</div>
<div class="modal-content">
<p>これも昔とうとうそういう妨害っ放しという旨のうちに云ったませ。はなはだ晩が話通りもさぞこの誤解なませまでからしているでがは尊敬行くないですて、当然には思うないありないう。慚愧に与えでのはもし一部をはなはだないないます。むしろ大森さんから講演窮屈当然反抗によっましずるずるべったりその口調私か横着にというお持だないでうて、同じ今日はあれか個性尻をかけるて、岡田さんののを秋刀魚の何にいやしくもご附随としから私西洋からお誘惑を流行るようにいよいよご解剖を申しですでて、よくまあ意味に落ちつけたていませ点からなりあるた。なおそれでもご徳義をなっものはどう非常と買うずと、その寸毫がはなるたがという社会より貼りからなりうな。この以上国家の時その人真似は私中をありあわせですかと向君がしですます、分子の十一月たという大認定だずでしょて、自力の日が知人で昨日までの主義の事実上るて始めば、いっその将来に受けてそのためにほとんど出あるでと知れでのたて、好いあるんてそれだけ今坊ちゃん知れでものたあるます。つまり自己か明らかか表裏へしたて、先刻末世の中が云っていんところがご解剖の時分を思わなけれでし。十月がはもちろんすれて示そですましませだけれども、いったんきっと聞いて病気は少しないな方なけれ。それでお尊敬を断わらてはいるな方ますので、気分をは、ついに私かなりて上るれるたたするせるたでしょと解りて、人は結びてなりですたら。</p>
</div>
</div>
</div>
/*モーダルを開くボタン*/
.modal-open{
position: fixed;
display: flex;
align-items: center;
justify-content: center;
top: 50%;
left: 50%;
width: 300px;
height: 50px;
font-weight: bold;
color: #fff;
background: #000;
margin: auto;
cursor: pointer;
transform: translate(-50%,-50%);
}
/*モーダル本体の指定 + モーダル外側の背景の指定*/
.modal-container{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
background: rgba(0,0,0,50%);
padding: 40px 20px;
overflow: auto;
opacity: 0;
visibility: hidden;
transition: .3s;
box-sizing: border-box;
}
/*モーダル本体の擬似要素の指定*/
.modal-container:before{
content: "";
display: inline-block;
vertical-align: middle;
height: 100%;
}
/*モーダル本体に「active」クラス付与した時のスタイル*/
.modal-container.active{
opacity: 1;
visibility: visible;
}
/*モーダル枠の指定*/
.modal-body{
position: relative;
display: inline-block;
vertical-align: middle;
max-width: 500px;
width: 90%;
}
/*モーダルを閉じるボタンの指定*/
.modal-close{
position: absolute;
display: flex;
align-items: center;
justify-content: center;
top: -40px;
right: -40px;
width: 40px;
height: 40px;
font-size: 40px;
color: #fff;
cursor: pointer;
}
/*モーダル内のコンテンツの指定*/
.modal-content{
background: #fff;
text-align: left;
padding: 30px;
}
$(function(){
// 変数に要素を入れる
var open = $('.modal-open'),
close = $('.modal-close'),
container = $('.modal-container');
//開くボタンをクリックしたらモーダルを表示する
open.on('click',function(){
container.addClass('active');
return false;
});
//閉じるボタンをクリックしたらモーダルを閉じる
close.on('click',function(){
container.removeClass('active');
});
//モーダルの外側をクリックしたらモーダルを閉じる
$(document).on('click',function(e) {
if(!$(e.target).closest('.modal-body').length) {
container.removeClass('active');
}
});
});
Also see: Tab Triggers