Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                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)
  
              
            
!

CSS

              
                $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)
              
            
!

JS

              
                $(".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)
    }
  })
}
              
            
!
999px

Console