文章加密

;

2020年5月27日 星期三

[CSS] box-sizing: border-box; & grid & [attribute*=value] Selector & flex

[ box-sizing: border-box; ]
The code below ensures that all elements are sized in this more intuitive way. Many browsers already use box-sizing: border-box; for many form elements (but not all - which is why inputs and text areas look different at width: 100%;).

{
  box-sizing: border-box;
}


[ grid ]
簡單說明含意,grid是一列(row)由12 column組成,因為column是float的,row要clear the flow,最後在加工美化一下,得出:
https://www.w3schools.com/css/css_rwd_grid.asp 裡面有詳細的code

實際使用
.grid-container {
  display: grid | 
inline-grid;
  grid-gap: 50px 100px// shorthand of  grid-row-gap and grid-column-gap
  grid-template-columns: auto auto 70px 120px// Make a grid with 4 columns
  grid-template-rows: 80px 200px;  // Make a grid with 2 rows
  grid-template-columns: 3fr 1fr;  // 新的 fr 單位之格線。fr 單位就是為了格線布局而生,代表格線容器內,可用空間的分塊(fraction)。

  grid-template-rows: repeat(3,auto);  // 即為  grid-template-rows: auto auto auto;
  justify-content: space-evenly | space-around | space-between | center | start | end// The grid's total width has to be less than the container's width
  align-contentspace-evenly | space-around | space-between | center | start | end;  // The grid's total height has to be less than the container's height
}

.item1 {
  grid-column: 1 / 5// 
shorthand of grid-column-start and grid-column-end
  grid-column: 1 / span 3// grid-column-start 跨三個跨度
  grid-row: 1 / 4;
  grid-row: 1 / span 2;
  grid-area: 1 / 2 / 5 / 6; // 上左下右, 記憶點:畢竟start應該先,所以非上右下左
  grid-area: 2 / 1 / span 2 / span 3;
  }

[CSS [attribute*=value] Selector]

Set a background color on all <div> elements that have a class attribute value containing "test":
div[class*="test"] {
  background: #ffff00;
}


Set a background color on all elements that have a class attribute value containing "test":
[class*="test"] {
  background: #ffff00;
}


[flex]
.flex-container {
  display: flex;

  flex-direction: column | column-reverse | row | row-reverse;
  flex-wrap: wrap | nowrap | wrap-reverse// The wrap value specifies that the flex items will wrap if necessary; The wrap-reverse value does the same but in reverse order:
  flex-flow: row wrap; // shorthand of flex-direction and flex-wrap
   justify-content: center | flex-start | flex-end | space-around | space-between;
  align-items: center | flex-start | flex-end | stretch | baseline; // The stretch value stretches the flex items to fill the container (this is default)
  //  Note: the example uses different font-size to demonstrate that the items gets aligned by the text baseline:
 align-content: space-between | space-around | center | flex-start | flex-end | stretch;
 // align-content v.s. align-items : 前者是針對所有元素相對container的位置,後者是針對所有元素彼此間的位置
}

.item1{
 order:1; // default value is 0. The bigger the value bigger, the more previous the order.
 flex-grow:2// Make the item grow 2 times faster than the other flex items, default value is 0.(這個item會是兩倍大於數字1的,但英文再w3c他就是那樣寫的~)
 flex-shrink:0// Make the third item shrink 2 times than the ones which are "flex-shrink:1", default value is 1.
 flex-basis: 200px; // The flex-basis property specifies the initial length of a flex item.
 flex: 0 0 200px;  // shorthand of flex-grow, flex-shrink, and flex-basis. Make the item not growable (0), not shrinkable (0), and with an initial length of 200 pixels. And its default value is 0 1 auto.
 flex: 25%; 
// flex:25% sets the flex-basis property to 25%, and also sets the flex-grow and flex-shrink properties to 1.
 align-self: center; // overrides the default alignment set by the container's align-items property. 功能和container's align-items一樣,不過是作用在單個item上
}

# example: the third one is flex-shrink:0and others are default.
<div class="flex-container">
  <div>1</div>
  <div>2</div>
  <div style="flex-shrink: 0">3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
  <div>7</div>
  <div>8</div>
  <div>9</div>
  <div>10</div>
</div>

# div內的文字過多時默認不會換行,須加上
.container{
  overflow:hidden;
  word-wrap:break-word; //定義怎麼斷過長的文案。break-all:不管,直接斷。normal:找到單詞間的空白再斷。
  word-break:break-all;  // 不管,直接斷
}
      錯錯錯!!!應該設basis !! (下面有例子)
  1. [flex v.s. grid]
  2. https://www.webdesignerdepot.com/2018/09/grid-vs-flexbox-which-should-you-choose/
  • In flexbox layout, the size of a cell (flex-item) is defined inside the flex-item itself, and in the grid layout, the size of a cell (grid-item) is defined inside the grid-container.
  • Grid Has a “Gap” Property, Flexbox Doesn’t.
  • Flexbox is One Dimensional, Grid is Two Dimensional
  • Flexbox Wraps vs Grid Wraps
  • Will CSS Grid make Flexbox Obsolete in the Future? Absolutely not, they both are designed to solve a different set of problems.
    <h2>Flexbox</h2>
    <div class="row-flex">
        <div>1 2 3  4 5 6 7 8 9 0</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
    </div>
     
    <h2>Grid</h2>
    <div class="row-grid">
        <div>1 2 3  4 5 6 7 8 9 0</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
    </div>

      /* Flexbox row styles */
      .row-flex {
        margin: 40px auto;
        max-width: 600px;
        display: flex;
        flex-wrap: wrap;
      }
      .row-flex div {
        border: 1px dashed gray;
        flex: 1 1 100px;  // set the basis
        text-align: center;
        padding: 12px;
      }
      /* Grid row styles */
      .row-grid {
        margin: 40px auto;
        max-width: 600px;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); // set the basis
      
      }
      .row-grid div {
        border: 1px dashed gray;
        text-align: center;
        padding: 12px;
      }


    when a flex-item is wrapped and pushed in a new row, the Flexbox layout algorithm treats it as a part of a different flex-container. Hence the pushed item loses its context.

    Flexbox and Grid layouts are built on concept of responsiveness and hence reduce the use of Media Queries.

    This is an important difference. It shows that the flexbox layout is calculated after its content is loaded whereas the grid layout is calculated regardless of the content inside it. So, if possible, avoid using flexbox to build the overall layout of your website.

2020年5月8日 星期五

在中國客戶口中的H5是什麼?原來不是Html5…,還附H5小遊戲代碼

1.
https://medium.com/@chiayenchiu/%E5%88%B0%E5%BA%95%E5%AE%A2%E6%88%B6%E5%8F%A3%E4%B8%AD%E7%9A%84h5%E6%98%AF%E4%BB%80%E9%BA%BC-html5-ac75678c29ff    在中國客戶口中的H5是什麼?原來不是Html5…

原來H5就是在微信裡,透過公眾號或是朋友圈發文的一個連結,點開後會在微信內部瀏覽器開啟一個類似移動端的活動網頁,原來這就是傳說中的H5!
H5的起源很可能是在HTML5發佈並且標準制訂完成的時間左右,先被工程師運用到手機端的活動、行銷頁面,行銷人員或其他人看到酷炫的頁面,詢問工程師後發現是最新標準HTML5製作的,接著行銷或業務在向客戶demo酷炫頁面時,可能就陰錯陽差或是簡稱這新技術叫H5,於是慢慢往外擴散,積非成是,漸漸地大家就都叫這種在微信好友之間分享、轉發的活動或行銷頁面為H5。
由於太多公司或品牌都把H5當作一個透過微信、QQ宣傳的行銷工具,坊間紛紛出現H5速成班(其實就是教授前端技術與知識吧!)、H5行銷等等,甚至還有很多製作H5的模版網站,有MAKA人人秀易秀網等,族繁不及備載,不需具備程式背景,就可以在這些模版網站上拖拉素材、新增頁面、製作動畫效果,有興趣的朋友可以來試試呀!

2.
https://m.html.cn/qa/html5/11792.html  简单的html5小游戏推荐(附代码)
刪除H5遊戲的研究是因為;
前端开发工程师对html5游戏开发一无所知再正常不过了,毕竟几乎完全是两个不同方向:
前端和html/css/js打交道比较多,是基于DOM的(不太会表述,能懂就行)。html5游戏则主要是canvas/js,核心在画布上。开发html5游戏的,不一定会前端,反之亦然。
java web开发者学习Android游戏开发也会有不小门槛。

3.H5模板,如廣宣
向這些網站提供的,MAKA、人人秀( https://rrx.cn/ )、易秀網,但我覺得那也是canvas
差不多可以說H5網頁=canvas製作網頁
雖然H5遊戲可能不必要,但H5廣宣我倒覺得很需要,這是一個需要會代碼又會美術的職業,他絕不會被定義為美術,而真正他會被視為可以製作H5遊戲!
https://rrx.cn/storeview/vtolch.html  廣宣
http://xcdn.php.cn/js/html5/H5%203D%E6%BB%9A%E7%90%83%E6%B8%B8%E6%88%8F%E6%BA%90%E7%A0%81/index.html?sign=cdd1b11d2ae7afeb7f5c1816f9b8faef&timestamp=1588951871  遊戲

2020年4月2日 星期四

TCP, handshake,dns

網域名稱系統(DNS:Domain Name System):

先思考一個有趣的問題,全世界的網址那麼多,一台 DNS 伺服器怎麼可能知道這麼多網址對應的 IP 位址是什麼呢?為了要解決這個問題,我們把全世界所有的網址區分為許多不同的「網域(Domain)」,並且定義了不同的層級

  1. root domain: 根網域是 DNS 架構最上層的伺服器,全球共約 16 台,當下層的任何一台 DNS 伺服器無法查出某個網址對應的 IP 位址時,則會向最上層負責根網域的 DNS 伺服器查詢。一個新網址訪問時,會先到root在一步步往下查詢。
  2. top level domain (TLD)
  3. second level domain
  4. host domain
https://www.stockfeel.com.tw/dns-%E4%BC%BA%E6%9C%8D%E5%99%A8%E6%98%AF%E4%BB%80%E9%BA%BC%EF%BC%9F%E5%A6%82%E4%BD%95%E9%81%8B%E7%94%A8%EF%BC%9F/

handshake:

https://www.chainnews.com/zh-hant/articles/930260468603.htm
 //還沒看 "Handshake 的三大功能 "
https://hsd-dev.org/ 官網
https://www.chainnews.com/zh-hant/articles/452340854508.htm 其他

2020年4月1日 星期三

stack: 栈是一种遵从后进先出(LIFO)原则的有序集合

注意!javascript本身function已經足夠,再建一個stack類與prototype添加function不太必要。
下面僅是利用javascript了解stack,因為本身比較熟javascript
stack用在c++,建構list等等,python應該也有

https://juejin.im/post/5b2323896fb9a00e8f795e5b


leetcode考題
/**
 * Initialize your data structure here.
 */
var MyStack = function() {
this.item=[]
};

/**
 * Push element x onto stack. 
 * @param {number} x
 * @return {void}
 */
MyStack.prototype.push = function(x) {
  this.item.push(x)
};

/**
 * Removes the element on top of the stack and returns that element. 並
* 不是說第一個元素,栈是一种遵从后进先出(LIFO)原则的有序集合,故此處的棧是最後進入的元素
 * @return {number}
 */
MyStack.prototype.pop = function() {
return this.item.pop()
};

/**
 * Get the top element.
 * @return {number}
 */
MyStack.prototype.top = function() {
return this.item[this.item.length-1]
};

/**
 * Returns whether the stack is empty.
 * @return {boolean}
 */
MyStack.prototype.empty = function() {
return this.item.length==0
};

/**
 * Your MyStack object will be instantiated and called as such:
 * var obj = new MyStack()
 * obj.push(x)
 * var param_2 = obj.pop()
 * var param_3 = obj.top()
 * var param_4 = obj.empty()
 */

面試


  1. flex, grid 
  2. 為什麼for迴圈的效能不好?優化他?
  3. for裡面放setTimeout經典題
  4. promise, resolve, reject
  5. capturing, bubbling,
  6. aurhorization, localStorage, cookie

1.
FOUC
http2
html5


2.
會傳到後端
cookie,

不會傳到後端
sessionStorage (不可以跨tab)
localStorage (可以跨tab)

3.
script 會等到資源載完才往下執行

加上async 會載資源的同時解讀下面的code,等資源載完就執行code

defer則是比async再加上要等的頁面document.ready(dom解析完)再執行

4.
為了效能的考量,把css放在head之間,js放在/body之前,是要讓畫面能最先被看見,互動的部分最晚再執行