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.
#app
.title.pagetitle Boss Coding - IOS Calender
.phone
.calender(v-if="days.length>0")
.head.flex.row
.tag(v-for="tag in tags") {{tag}}
.body.flex
.daybox(v-for="(d,day_id) in days" ,:style="get_pan(d)" , :key="d",v-if="d",:class="{active: selected==day_id}" ,@click="selected=day_id")
.infos
.num {{d.number}}
.lunar {{ lunar(d.lunar) }}
.eventdot(:class="{has_event: d.events.length>0}")
transition-group.todo_list(tag="div",name="fade",mode="out-in")
.item(v-for="(todo,id) in current_items",:class="'type_'+todo.type",:key="todo",v-if="todo")
.time {{todo.time}}
.title {{todo.title}}
.close_btn(@click="current_items.splice(id,1)") x
.form
input(name="title" v-model="newtodo.title" placeholder="標題")
input(name="time" v-model="newtodo.time" placeholder="時間")
select(name="type" v-model="newtodo.type" placeholder="種類")
option(value="work") 工作
option(value="important") 重要
option(value="school") 學校
button(type="submit" @click="add_item") +
@mixin size($w,$h: $w)
width: $w
height: $h
@mixin flex_center
display: flex
align-items: center
justify-content: center
flex-direction: column
*
position: relative
font-family: 'Roboto', '微軟正黑體'
html,body,#app
+size(100%)
background-color: #333
+flex_center
color: #555
.phone
+size(360px,560px)
background-color: #fff
box-shadow: 0px 0px 10px rgba(black,0.6)
overflow: hidden
.flex
display: flex
&.row
flex-direction: row
.calender
.head,.body
border-bottom: solid 1px rgba(black,0.1)
background-color: #f7f7f7
.head
padding-top: 50px
padding-bottom: 5px
.tag
width: calc(100% / 7)
text-align: center
font-size: 12px
.body
flex-wrap: wrap
padding-bottom: 10px
.daybox
box-sizing: border-box
width: calc(100% / 7)
text-align: center
padding: 5px 0px
cursor: pointer
// border-radius: 50%
// border: solid 1px
position: relative
display: flex
flex-direction: column
align-items: center
.infos
display: flex
flex-direction: column
align-items: center
// transition: 0.1s
&.active
color: white
.infos
background-color: #111
.infos
+size(40px)
border-radius: 50%
.num
font-weight: 500
font-size: 20px
margin-top: 5px
.lunar
font-size: 12px
margin-top: 1px
.eventdot
+size(6px)
background-color: #ddd
border-radius: 50%
margin-top: 5px
opacity: 0
&.has_event
opacity: 1
.todo_list
.item
padding: 3px 10px
display: flex
height: 40px
border-bottom: solid 1px rgba(0,0,0,0.1)
transition: 0.5s
&:hover
background-color: #fafafa
.close_btn
opacity: 1
.close_btn
position: absolute
top: 50%
right: 20px
transform: translateY(-50%)
cursor: pointer
opacity: 0
transition: 0.5s
.time,.title
padding: 4px 10px
.time
width: 55px
border-right: solid 2px
border-color: #3ca9f2
&.type_work
.time
border-color: #57ef34
&.type_important
.time
border-color: #3ca9f2
&.type_school
.time
border-color: #f9bf59
.form
box-sizing: border-box
padding: 10px
position: absolute
bottom: 0px
width: 100%
left: 0
+flex_center
flex-direction: row
input,select
box-sizing: border-box
margin-right: 10px
padding: 5px 10px
border-radius: 2px
min-width: 150px
height: 30px
color: white
background-color: transparent
border: none
border: solid 1px white
input[name='title']
width: 300px
.pagetitle
color: white
font-size: 20px
margin-bottom: 20px
.fade-enter-active,.fade-leave-active
transition: 0.5s
.fade-enter,.fade-leave-to
opacity: 0
var vm = new Vue({
el: "#app",
data: {
tags: "日一二三四五六",
days: [],
start_day: 1,
selected: 25,
newtodo: {
title: "",
time: "",
type: "important",
}
},
mounted() {
var lunar=6;
for(var i=1;i<=31;i++){
var new_day={
number: i,
lunar: lunar,
events: []
};
if (Math.random()<0.4){
var count=Math.random()*3;
for(var o=0;o<count;o++){
var minute=parseInt(Math.random()*3)*15;
new_day.events.push(
{title: ["整理房間丟垃圾","出門參加活動","打包行李"][parseInt(Math.random()*3)],
place: "我的家裡",
unique_id: Math.random()*100,
time: parseInt(Math.random()*24)+":"+(minute==0?"0":"")+minute,
type: ["work","important","school"][parseInt(Math.random()*3)],
}
);
}
}
this.days.push(new_day);
lunar++;
// start_day++;
}
},
methods:{
chinese_num(num){
var list="十一二三四五六七八九";
return list[num];
},
lunar(num){
if (num>30) num=num%30;
if (num<11){
return "初"+this.chinese_num(num%10) ;
}else if (num<20){
return "十"+this.chinese_num(num%10);
}else if (num==20){
return "二十";
}else if (num<30){
return "廿"+this.chinese_num(num%10);
}else if (num<40){
return "三"+this.chinese_num(num%10);
}
},
get_pan(d){
if (d.number==1){
return { "margin-left": "calc( "+this.start_day+" * 100% / 7)"};
}
},
add_item(){
this.current_day.events.push(JSON.parse(JSON.stringify(this.newtodo )));
}
},computed: {
current_day(){
return this.days[this.selected];
},
current_items(){
var day=this.current_day;
if(!day)
return null;
else
return day.events
.sort((a,b)=>(parseInt(a.time.replace(":",""))-parseInt(b.time.replace(":","")) ));
}
}
});
Also see: Tab Triggers