<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CSS | SDT 攻城獅區</title>
	<atom:link href="https://sdt.hameba.tw/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>https://sdt.hameba.tw</link>
	<description>由Steven, Der, Ted 三位高級打字員所組成，是三位工程師(攻城獅)所維護的技術分享平台，或許偶爾會分享一些日常，有任何問題或是錯誤的部分，歡迎留言告訴我們！</description>
	<lastBuildDate>Fri, 28 Feb 2020 13:35:10 +0800</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.3</generator>

<image>
	<url>https://sdt.hameba.tw/wp-content/uploads/2020/02/hameba_favicon-150x150.png</url>
	<title>CSS | SDT 攻城獅區</title>
	<link>https://sdt.hameba.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>CSS 視窗捲動效果</title>
		<link>https://sdt.hameba.tw/596/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=css-%25e8%25a6%2596%25e7%25aa%2597%25e6%258d%25b2%25e5%258b%2595%25e6%2595%2588%25e6%259e%259c</link>
				<comments>https://sdt.hameba.tw/596/#respond</comments>
				<pubDate>Fri, 28 Feb 2020 13:35:10 +0000</pubDate>
		<dc:creator><![CDATA[Ted]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[scroll-behavior]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=596</guid>
				<description><![CDATA[<p>在做網頁的時，我們為了要讓某些連結點了之後移動到適當的位置，我們會透過 HTML anchor link 定義 &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/596/" class="more-link">閱讀全文<span class="screen-reader-text">〈CSS 視窗捲動效果〉</span></a></p>
The post <a href="https://sdt.hameba.tw/596/">CSS 視窗捲動效果</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>在做網頁的時，我們為了要讓某些連結點了之後移動到適當的位置，我們會透過 HTML anchor link 定義此連結，達到上述的功能。</p>
<p><span id="more-596"></span></p>
<p>不過這個功能的體驗，感覺就是閃一下，就跳到要顯示的位置上，感覺並不怎麼好，所以這時候就可以使用 CSS 屬性 <code>scroll-behavior</code> 來達到平滑移動的效果啦。</p><pre class="crayon-plain-tag">// scroll-behavior

html {
    scroll-behavior: smooth
}</pre><p>不過此 scroll-behavior CSS 屬性好像並不支援 safari 瀏覽器，所以如果也想要支援 safari 瀏覽器的朋友們，可能就要換另外一種方法了。</p>
<p>參考連結：<a href="https://developer.mozilla.org/zh-CN/docs/Web/CSS/scroll-behavior">https://developer.mozilla.org/zh-CN/docs/Web/CSS/scroll-behavior</a></p>
<div id="gtx-trans">
<div class="gtx-trans-icon"></div>
</div>The post <a href="https://sdt.hameba.tw/596/">CSS 視窗捲動效果</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/596/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>CSS 圖片旋轉功能，減少art出圖</title>
		<link>https://sdt.hameba.tw/505/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=css-%25e5%259c%2596%25e7%2589%2587%25e6%2597%258b%25e8%25bd%2589%25e5%258a%259f%25e8%2583%25bd%25ef%25bc%258c%25e6%25b8%259b%25e5%25b0%2591art%25e5%2587%25ba%25e5%259c%2596</link>
				<comments>https://sdt.hameba.tw/505/#respond</comments>
				<pubDate>Sun, 02 Feb 2020 05:01:14 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[transform]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=505</guid>
				<description><![CDATA[<p>有些前端工程師很喜歡叫art出圖，連旋轉其實都是可以用css做到， 但卻懶到什麼都叫art來做，造成art很討 &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/505/" class="more-link">閱讀全文<span class="screen-reader-text">〈CSS 圖片旋轉功能，減少art出圖〉</span></a></p>
The post <a href="https://sdt.hameba.tw/505/">CSS 圖片旋轉功能，減少art出圖</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>有些前端工程師很喜歡叫art出圖，連旋轉其實都是可以用css做到，</p>
<p>但卻懶到什麼都叫art來做，造成art很討厭工程師 XDDD !</p>
<p><span id="more-505"></span></p>
<p>CSS的 transform 屬性可以讓網頁元素變形，呈現多種的特殊效果，其中之一便是旋轉效果，可以自由設定元素順時針或逆時針旋轉幾度。</p>
<div>寫法為rotate(θ)</div>
<div>指定元素以參考點為中心軸旋轉θ度。</div>
<div>θ 參數須有標示單位，例如： deg (角度)、rad (弧度) 、grad (梯度)</div>
<div>正數為順時針旋轉，負數反之為逆時針。</div>
<div></div>
<div>
<pre class="crayon-plain-tag">div{
  background:#4d4d4d;
  color:#fff;
  width:150px;height:30px;padding:15px;
  text-align:center;
  -moz-transform:rotate(5deg);
  -webkit-transform:rotate(5deg);
  -o-transform:rotate(5deg);
  -ms-transform:rotate(5deg);
  transform:rotate(5deg);
}</pre>
</div>
<p>幾行簡單的程式碼就搞定，也可以不用讓art，還要開photoshop 調整角度，等等差一度又要再重新出圖。</p>
<p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://www.webdesigns.com.tw/css_rotate.asp" target="_blank" rel="noopener noreferrer">https://www.webdesigns.com.tw/css_rotate.asp</a></p>The post <a href="https://sdt.hameba.tw/505/">CSS 圖片旋轉功能，減少art出圖</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/505/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>CSS 文字換行，強迫不換行。</title>
		<link>https://sdt.hameba.tw/503/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=css-%25e6%2596%2587%25e5%25ad%2597%25e6%258f%259b%25e8%25a1%258c%25ef%25bc%258c%25e5%25bc%25b7%25e8%25bf%25ab%25e4%25b8%258d%25e6%258f%259b%25e8%25a1%258c%25e3%2580%2582</link>
				<comments>https://sdt.hameba.tw/503/#respond</comments>
				<pubDate>Sun, 02 Feb 2020 04:18:28 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[word-break]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=503</guid>
				<description><![CDATA[<p>換行在畫面開發設計上，常常會用於內容過多造成破版的問題， 此篇可以配合CSS「text-overflow: e &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/503/" class="more-link">閱讀全文<span class="screen-reader-text">〈CSS 文字換行，強迫不換行。〉</span></a></p>
The post <a href="https://sdt.hameba.tw/503/">CSS 文字換行，強迫不換行。</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>換行在畫面開發設計上，常常會用於內容過多造成破版的問題，</p>
<p>此篇可以配合<a href="https://sdt.hameba.tw/501/" target="_blank" rel="noopener noreferrer">CSS「text-overflow: ellipsis;」屬性限制內容字數，顯示「…」</a>應用，</p>
<p><span id="more-503"></span></p>
<p>CSS 文字換行的 style 為 word-wrap ，透過這個屬性可以指定換行的方式，並可以強制文字不換行。</p>
<p>而 CSS 還有個空白長度的設定，透過 white-space 可以移除連續空白。</p>
<ul class="list">
<li><span class="vj-cmd">word-break: break-all;</span> <b>文字強迫換行，太長的英文字，會自動切成兩半。</b>若一個單字過長，超過畫面的寬度，則將單字切斷，並換行。</li>
<li class="li1"><span class="s2">word-wrap:break-word; </span><b>文字自動換行，長英文字不切斷，</b>若一個單字過長，超過畫面的寬度，則將單字換行<span class="s2">(</span>不切斷單字<span class="s2">)</span>。不切斷英字單字對於一般的讀者是比較好懂的，唯一的缺點是右邊會出現很大的一塊空白。</li>
<li>white-space:pre; 保留原始資料的空白與換行，功能與 HTML tag 中的 ＜pre&gt; 相同。</li>
<li>white-space:nowrap; 強迫文字不換行，移除連續空白，移除換行符號(n r)， 強迫文字不換行。</li>
<li>white-space:pre-wrap; 保留所有空白，自動換行。</li>
<li>white-space: pre-line; 連續空白，取代成一個空白。這個語法可以會自動將多個空白轉換成一個空白。</li>
</ul>The post <a href="https://sdt.hameba.tw/503/">CSS 文字換行，強迫不換行。</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/503/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>CSS「text-overflow: ellipsis;」屬性限制內容字數，顯示「&#8230;」</title>
		<link>https://sdt.hameba.tw/501/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=css%25e3%2580%258ctext-overflow-ellipsis%25e3%2580%258d%25e5%25b1%25ac%25e6%2580%25a7%25e9%2599%2590%25e5%2588%25b6%25e5%2585%25a7%25e5%25ae%25b9%25e5%25ad%2597%25e6%2595%25b8%25ef%25bc%258c%25e9%25a1%25af%25e7%25a4%25ba%25e3%2580%258c-%25e3%2580%258d</link>
				<comments>https://sdt.hameba.tw/501/#respond</comments>
				<pubDate>Sun, 02 Feb 2020 03:05:23 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[ellipsis]]></category>
		<category><![CDATA[React.js]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=501</guid>
				<description><![CDATA[<p>在做畫面的title, content時永遠最大的問題就是可恨的過多字數爆版問題， 所以可以透過CSS Sty &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/501/" class="more-link">閱讀全文<span class="screen-reader-text">〈CSS「text-overflow: ellipsis;」屬性限制內容字數，顯示「&#8230;」〉</span></a></p>
The post <a href="https://sdt.hameba.tw/501/">CSS「text-overflow: ellipsis;」屬性限制內容字數，顯示「…」</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>在做畫面的title, content時永遠最大的問題就是可恨的過多字數爆版問題，</p>
<p>所以可以透過CSS Style來解決初步的問題，</p>
<p><span id="more-501"></span></p>
<p>在&lt;p&gt;&lt;/p&gt;的部分，不希望因為過多文字換行可以使用此方式:</p><pre class="crayon-plain-tag">p {
overflow:hidden;
white-space: nowrap;
text-overflow: ellipsis;
}</pre><p>原文字的內容當過多時，就不換行改為「&#8230;」。</p>
<p>另一種方式直接使用js對文字做過多處理為「&#8230;」</p><pre class="crayon-plain-tag">// 以React function為示範, 將要換的內容值放入做取代
renderContentLimit(p){
    const len = 50; // 超過50個字以"..."取代
    console.log(p.length);
    if(p.length&gt;len){
        const final=p.substring(0,len-1)+"...";
        return final
    }
    else{
        return p
    }

}</pre><p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://www.astralweb.com.tw/css-ellipsis/" target="_blank" rel="noopener noreferrer">https://www.astralweb.com.tw/css-ellipsis/</a></p>The post <a href="https://sdt.hameba.tw/501/">CSS「text-overflow: ellipsis;」屬性限制內容字數，顯示「…」</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/501/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>網頁 scroll bar 顯示</title>
		<link>https://sdt.hameba.tw/458/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=css-overflow-%25e5%25b1%25ac%25e6%2580%25a7</link>
				<comments>https://sdt.hameba.tw/458/#respond</comments>
				<pubDate>Sun, 05 Jan 2020 16:09:22 +0000</pubDate>
		<dc:creator><![CDATA[Ted]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=458</guid>
				<description><![CDATA[<p>之前 PM 有需求，說想要頁面上 scroll bar 會一直出現，不要等滑動的時候才顯示， 所以做了一些 C &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/458/" class="more-link">閱讀全文<span class="screen-reader-text">〈網頁 scroll bar 顯示〉</span></a></p>
The post <a href="https://sdt.hameba.tw/458/">網頁 scroll bar 顯示</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>之前 PM 有需求，說想要頁面上 scroll bar 會一直出現，不要等滑動的時候才顯示，</p>
<p>所以做了一些 CSS scroll bar 的屬性的測試，這邊做一下記錄。</p>
<p><span id="more-458"></span></p><pre class="crayon-plain-tag">// 滑動時，才會顯示。
.test {
overflow: scroll;
}

// 不滑動時，如果內容長度有超過限制的高度，也會顯示。
.test {
overflow: auto;
}</pre><p>不過這邊值得注意的一點是， windows 系統跟 mac 不太一樣，上面的設定在 window 執行的很順利，在 mac 上，還需要做一些額外的設定，才可以達到不滑動時，也出  scroll bar 的效果。</p><pre class="crayon-plain-tag"># mac 設定

# 系統偏好設定 -&gt; 一般 -&gt; 顯示捲軸 -&gt; 勾選 (總是)

# 完成以上設定就可以了。</pre><p>&nbsp;</p>
<div id="gtx-trans">
<div class="gtx-trans-icon"></div>
</div>The post <a href="https://sdt.hameba.tw/458/">網頁 scroll bar 顯示</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/458/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
	</channel>
</rss>
