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.
form(action="https://2017.awiclass.monoame.com/api/demo/feedback" method="post")
img(src="https://2017.awiclass.monoame.com/img/form_leaf.svg", alt="")
h2 請幫助我們變得更好!
input(name="name", placeholder="你的名字")
select(name="option")
option(value="" disabled selected) 使用產品
option(value="白毫烏龍") 白毫烏龍
option(value="茉莉綠茶") 茉莉綠茶
option(value="伯爵紅茶") 伯爵紅茶
textarea(name="comment",
placeholder="使用心得",
rows = "8")
.recommand
input(type="radio" name="recommand" value="yes")
label 會推薦給朋友
input(type="radio" name="recommand" value="no")
label 不推薦
input(name="json", type="hidden" value="")
.feedback
button 送出意見
button.ajaxbtn 送出意見(AJAX)
$colorGreen: #DFFF47
$colorBrown: #37382F
$colorLightBrown: #383931
@mixin size($w, $h:$w)
width: $w
height: $h
*
// outline: 1px solid #000
html
background-color: lighten($colorBrown, 3)
background-image: url(https://2017.awiclass.monoame.com/img/form_ground.svg)
background-size: 100% auto // 左右填滿上下自動
background-repeat: no-repeat
background-position: 0 80% // 左右是0下降到80%
body
display: flex
justify-content: center
align-items: center
min-height: 100vh
form
background-color: $colorLightBrown
color: white
padding: 30px 100px
display: flex // 預設由左而右
flex-direction: column // 改成由上而下
max-width: 300px
letter-spacing: 1px
img
width: 120px
margin-left: auto
margin-right: auto
&>*
margin-bottom: 15px // 選擇form下面所有元素
h2
font-weight: normal
text-align: center
margin-bottom: 20px
input, textarea, select
padding: 8px 15px
font-size: 14px
border-radius: 0px // 移除下拉選單預設圓角
opacity: 0.9
outline: none // 移除預設的藍色外框
&::placeholder
color: rgba($colorBrown, 0.4)
select, input[type="radio"]
appearance: none // 取消瀏覽器預設樣式
// 讓兩個按鈕排整齊
.recommand
display: flex
align-items: center
margin-top: 10px
margin-bottom: 20px
label
margin-right: 40px
margin-left: 5px
// 取代原先的樣式自己寫
input[type="radio"]
padding: 0
+size(20px)
border: 2px solid white
border-radius: 50%
cursor: pointer
transition: 0.5s
&:checked
background-color: $colorGreen
border-color: $colorGreen
button
background-color: transparent
padding: 8px
color: white
cursor: pointer
&:hover
background-color: rgba(white, 0.1)
$(".ajaxbtn").click(function(evt){
evt.preventDefault()
console.log("ajax送出")
post()
})
function post(){
var datas = $("form").serializeArray()
datas.find(obj=>obj.name=='json').value="true"
console.log(datas)
$.ajax({
url: "https://2017.awiclass.monoame.com/api/demo/feedback",
method: "post",
data: datas,
success: function(res){
console.log("ajax result:")
console.log(res)
$(".feedback").text(res.response)
}
})
}
Also see: Tab Triggers