input的類型
- 主要在手機版比較好輸入
<input type="email" > <input type="tel" >
<input type="number">
<input type="email" > <input type="tel" >
<input type="number">
.myform .pure-form-stacked .pure-form-margin {
//自己的class,前面的也寫,是為了之後看得懂這個CSS在哪裡
margin: 1em 0;
}
<tr>
<td class="m-none">2000001</td>
<td>2018/02/05</td>
<td>王小名</td>
<td>冰箱</td>
<td>20000</td>
<td class="m-none"> //增加class
<input type="button" value="修改">
<input type="button" value="刪除">
</td>
</tr>
@media(max-width: 560px){
.m-none{
display: none
}
}
//讓他在特定的大小以下,就消失
overflow-x:auto
<div class="container">
<table class="order">
//省略
</table>
</div>
@media(max-width: 560px) {
.container {
overflow-x: auto;
}
.order {
width: 1000px;
}
}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@media (max-width:375px) {
#title {
color: black;
}
}
.wrap {
max-width: 900px;
margin: 0 auto;
}
.news li {
width: 31.3333%;
margin-left: 1%;
margin-right: 1%;
margin-bottom: 1em;
float: left;
}
@media(max-width:780px) {
.news li {
width: 48%;
}
}
@media(max-width:375px) {
.news li {
width: 99%;
}
}
window.onload = getchild
function getchild() {
var childrennode = document.querySelector("body").childNodes
console.log(childrennode)
}
<p id=“chos”>選擇圖片</p>
<script>
var chos = document.querySelector("#chosepic")
console.log(chos.nodeValue) //不會得到東西,因為chos是P標籤,而P標籤沒有屬性
console.log(chos.childNodes[0].nodeValue) //我們想要的是P標籤的子節點(文本節點)的屬性
</script>
<body>
<h1>練習</h1>
<ul>
<li>
<a title="nissen" onclick="change(this);return false;" href="./img/01.jpg">照片一</a>
</li> //return false可以阻止事件發生,this可以把自己當參數傳回去function
<li>
<a title="light" onclick="change(this);return false;" href="./img/02.jpg">照片二</a>
</li>
<li>
<a title="dark" onclick="change(this);return false;" href="./img/03.jpg">照片三</a>
</li>
</ul>
<img id="placeholder" src="./img/02.jpg" alt="">
<p id="chosepic">選擇圖片</p>
<script>
function change(picsrc) {
var source = picsrc.getAttribute("href") /
var placeholder = document.querySelector("#placeholder")
var text = picsrc.getAttribute("title")
var chosepic = document.querySelector("#chosepic")
placeholder.setAttribute("src", source)
chosepic.firstChild.nodeValue = text
}
</script>
</body>
<div class="wrap">
<div class="menu">
<ul>
<li>電腦</li>
<li>書本</li>
<li>食物</li>
</ul>
</div>
<div class="content">....一堆內容</div>
</div>
.wrap {
max-width: 980px;
margin: 0 auto;
}
.menu {
width: 200px; //可以寫死
float: left; //浮動
border: 1px solid #000;
}
.content {
padding: 10px;
margin-left: 200px; //往右推200px,然後寬度隨父元素自適應
background-color: orange;
}
@media(max-width:780px) {
.menu {
float: none; //清除浮動
width: 100%; //讓選單變成100%
}
}
@media(max-width:780px) {
.content {
margin-left: 0px; //清除右推
}
}
If的寫法 我們希望當變數是a時就回傳1,變數是b就回傳2,變數是c就會回傳3,一般寫法就是用if,但是這樣會很冗 // IF style var word if(word == 'a'){ word = 1 } else if...