<?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 &#8211; 李辉 / Grey Li</title>
	<atom:link href="https://greyli.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>https://greyli.com</link>
	<description>一个编程和写作爱好者的在线记事本</description>
	<lastBuildDate>Sat, 15 Nov 2025 10:55:15 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.26</generator>

<image>
	<url>https://greyli.com/wp-content/uploads/2025/03/avatar-500-compressed-144x144.jpg</url>
	<title>CSS &#8211; 李辉 / Grey Li</title>
	<link>https://greyli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>我的第一个Chrome扩展：GhostPage（网页X光）</title>
		<link>https://greyli.com/my-chrome-extension-ghostpage/</link>
		<comments>https://greyli.com/my-chrome-extension-ghostpage/#respond</comments>
		<pubDate>Fri, 22 Sep 2017 01:12:09 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[Chrome扩展]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[GhostPage]]></category>

		<guid isPermaLink="false">http://greyli.com/?p=1417</guid>
		<description><![CDATA[没有接触过Chrome扩展的时候，觉得它一定很复杂。crx的后缀也让我猜不出是用什么语言编写的，现在才发现不过 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>没有接触过Chrome扩展的时候，觉得它一定很复杂。crx的后缀也让我猜不出是用什么语言编写的，现在才发现不过就是HTML+CSS+JavaScript……</p>
<div id="attachment_1418" style="width: 1213px" class="wp-caption aligncenter"><img class="wp-image-1418 size-full" src="http://greyli.com/wp-content/uploads/2017/09/sp170922_085047.png" alt="GhostPage in Chrome" width="1203" height="931" srcset="https://greyli.com/wp-content/uploads/2017/09/sp170922_085047.png 1203w, https://greyli.com/wp-content/uploads/2017/09/sp170922_085047-150x116.png 150w, https://greyli.com/wp-content/uploads/2017/09/sp170922_085047-300x232.png 300w, https://greyli.com/wp-content/uploads/2017/09/sp170922_085047-1024x792.png 1024w, https://greyli.com/wp-content/uploads/2017/09/sp170922_085047-624x483.png 624w" sizes="(max-width: 1203px) 100vw, 1203px" /><p class="wp-caption-text"><a href="https://chrome.google.com/webstore/detail/ghostpage/hegpcollkgldlimbhkimijhhhoaicipp" target="_blank" rel="noopener">扩展GhostPage的Chrome商店页面</a></p></div>
<p>这个扩展本身很简单，实际只有一行代码。Google提供了一个非常好的<a href="https://developer.chrome.com/extensions/getstarted" target="_blank" rel="noopener">入门指导</a>，过一遍基本上就可以编写简单的扩展了。这个扩展作用也就是通过去掉页面样式来检查页面结构（参考<a href="http://greyli.com/white-space-appears-on-the-right-side-of-the-page-try-this-css-debugger/" target="_blank" rel="noopener">这篇文章</a>），可以用来解决下面的问题：</p>
<ul>
<li>元素超出边线，挤出的空白导致多余的平行滚动</li>
<li>元素不对齐</li>
</ul>
<p>使用这个扩展配合Chrome的检查工具可以快速的定位到出问题的元素。</p>
<p>Chrome商店的地址：<a href="http://greyli.com/wp-content/uploads/2017/09/sp170922_085047.png" rel="attachment wp-att-1418"><br />
</a><a href="https://chrome.google.com/webstore/detail/ghostpage/hegpcollkgldlimbhkimijhhhoaicipp" target="_blank" rel="noopener">https://chrome.google.com/webstore/detail/ghostpage/hegpcollkgldlimbhkimijhhhoaicipp</a></p>
<p>crx文件下载（备用）：<a href="https://chrome-extension-downloader.com/77577d1b5c39e945e597a9981f6e0ee6/hegpcollkgldlimbhkimijhhhoaicipp/GhostPage_v1.0.crx" target="_blank" rel="noopener">https://chrome-extension-downloader.com/77577d1b5c39e945e597a9981f6e0ee6/hegpcollkgldlimbhkimijhhhoaicipp/GhostPage_v1.0.crx</a></p>
<p>附注：虽然扩展编写很简单，但为了交5美元的开发者认证费用却花了我一天时间。尝试了下面几种方式均失败了：</p>
<ul>
<li>全球付</li>
<li>Google Play礼品卡</li>
<li>其他几个虚拟信用卡服务</li>
</ul>
<p>最后花了两倍多的价格在淘宝上买了一个虚拟信用卡，第二天中午扣款成功了。</p>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/my-chrome-extension-ghostpage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>页面右侧出现空白？试试这个CSS调试器！</title>
		<link>https://greyli.com/white-space-appears-on-the-right-side-of-the-page-try-this-css-debugger/</link>
		<comments>https://greyli.com/white-space-appears-on-the-right-side-of-the-page-try-this-css-debugger/#comments</comments>
		<pubDate>Sun, 06 Nov 2016 09:28:31 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://withlihui.com/?p=1197</guid>
		<description><![CDATA[很多新手在写CSS会遇到很多问题，比如发现页面右侧出现了很多空白。你在网上搜索了之后，发现使用这行代码可以解决 [&#8230;]]]></description>
				<content:encoded><![CDATA[<div class="Editable-unstyled" data-block="true" data-editor="9ligl" data-offset-key="3iooc-0-0">
<p class="Editable-unstyled" data-block="true" data-editor="bh3nk" data-offset-key="emak3-0-0">很多新手在写CSS会遇到很多问题，比如发现页面右侧出现了很多空白。你在网上搜索了之后，发现使用这行代码可以解决：</p>
</div>
<pre class="">body, html {
    overflow-x: hidden;
}</pre>
<p class="">但是虽然滚动条被隐藏了，问题并没有解决，你还是不知道是哪个元素在作怪。而且，隐藏了x向的滚动条会导致很多副作用，比如缩小浏览器后无法滚动。</p>
<h2 class=""><b>调试工具</b></h2>
<p class="">最佳的解决方法是使用一个CSS调试工具来把出问题的元素揪出来。你可以访问<a href="http://greyli.com/ghost.html">这个页面</a>，点击页面第二行的链接（Click me……），然后看看发生了什么……不用担心，刷新一下，页面就会恢复正常</p>
<p class=""><span data-offset-key="futbj-0-0">如果你使用Chrome浏览器，那么可以试试这个</span><a class="Link" href="https://chrome.google.com/webstore/detail/ghostpage/hegpcollkgldlimbhkimijhhhoaicipp" target="_blank" rel="noopener" data-offset-key="futbj-1-0" data-editable="true"><span data-offset-key="futbj-1-0">GhostPage</span></a><span data-offset-key="futbj-2-0">扩展。</span></p>
<h2 class=""><b>使用方法</b></h2>
<p class="">你可以拖拽这个链接到你浏览器的书签栏（或是使用上面提到的Chrome扩展），然后在任一个打开的页面，都可以通过点击这个书签来查看整个页面的元素结构。比如一开始我打开知乎的主页，是这样：</p>
<div id="attachment_1207" style="width: 1162px" class="wp-caption aligncenter"><img class="wp-image-1207 size-full" src="http://greyli.com/wp-content/uploads/2016/11/before.png" alt="知乎主页" width="1152" height="942" srcset="https://greyli.com/wp-content/uploads/2016/11/before.png 1152w, https://greyli.com/wp-content/uploads/2016/11/before-150x123.png 150w, https://greyli.com/wp-content/uploads/2016/11/before-300x245.png 300w, https://greyli.com/wp-content/uploads/2016/11/before-1024x837.png 1024w, https://greyli.com/wp-content/uploads/2016/11/before-624x510.png 624w" sizes="(max-width: 1152px) 100vw, 1152px" /><p class="wp-caption-text">正常的页面</p></div>
<p class="">当我点了这个书签，页面就变成了这样：</p>
<div id="attachment_1208" style="width: 1172px" class="wp-caption aligncenter"><a href="http://greyli.com/wp-content/uploads/2016/11/after.png" rel="attachment wp-att-1208"><img class="size-full wp-image-1208" src="http://greyli.com/wp-content/uploads/2016/11/after.png" alt="使用了Ghost CSS后的页面" width="1162" height="939" srcset="https://greyli.com/wp-content/uploads/2016/11/after.png 1162w, https://greyli.com/wp-content/uploads/2016/11/after-150x121.png 150w, https://greyli.com/wp-content/uploads/2016/11/after-300x242.png 300w, https://greyli.com/wp-content/uploads/2016/11/after-1024x827.png 1024w, https://greyli.com/wp-content/uploads/2016/11/after-624x504.png 624w" sizes="(max-width: 1162px) 100vw, 1162px" /></a><p class="wp-caption-text">使用了Ghost CSS后的页面</p></div>
<p class="">很神奇吧？</p>
<p class="">其实原理很简单，只是在页面的CSS文件里加入了这几行代码：</p>
<pre class="" lang="css">* {
    background: #000 !important;
    color: #0f0 !important;
    outline: solid #f00 1px !important;
}</pre>
<p class="">更改所有元素的背景，颜色和边框（你可以通过修改书签的链接内容来自定义颜色）。</p>
<p class="">在你的出现右侧空白问题的页面上，你会看到有一个元素一直顶到最右边的边界，修正这个元素就可以彻底的解决问题。这样，一旦页面出现了奇怪的问题时，你就可以通过点击这个书签来检查问题。把它放到你的日常开发工具箱里吧：）</p>
<p class="">方法来自：<a class="" href="http://wernull.com/2013/04/debug-ghost-css-elements-causing-unwanted-scrolling/" target="_blank" rel="noopener" data-editable="true" data-title="Debug Ghost CSS Elements Causing Unwanted Scrolling">Debug Ghost CSS Elements Causing Unwanted Scrolling</a></p>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/white-space-appears-on-the-right-side-of-the-page-try-this-css-debugger/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CSS笔记：Layout</title>
		<link>https://greyli.com/css-note-layout/</link>
		<comments>https://greyli.com/css-note-layout/#respond</comments>
		<pubDate>Sun, 25 Sep 2016 14:28:01 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://withlihui.com/?p=1096</guid>
		<description><![CDATA[目录 Display Position Overflow Float Align &#160; 一、Displ [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2>目录</h2>
<ul>
<li><a href="#display">Display</a></li>
<li><a href="#position">Position</a></li>
<li><a href="#overflow">Overflow</a></li>
<li><a href="#float">Float</a></li>
<li><a href="#align">Align</a></li>
</ul>
<p>&nbsp;</p>
<h2><a name="display"></a>一、Display</h2>
<p>元素的默认display值是block或inline。</p>
<h3>block</h3>
<p>block层级的元素总是新起一行，占全宽度。下面的元素默认为block：</p>
<p>&lt;div&gt; <br />&lt;h1&gt; &#8211; &lt;h6&gt; <br />&lt;p&gt; <br />&lt;form&gt;<br /> &lt;header&gt; <br />&lt;footer&gt; <br />&lt;section&gt;</p>
<p>如果不想让block元素占据全宽度，可以使用<code>width</code>属性设置宽度，同时，如果想让内容适应不同大小的屏幕，使用<code>max-width</code>。</p>
<h3>inline</h3>
<p>inline元素不新起一行，而且只占用需要的宽度。inline元素有：&lt;span&gt;、&lt;a&gt;、&lt;img&gt;</p>
<p>可以重写元素的display默认值来获得特殊效果。</p>
<h3>inline-block</h3>
<p>inline-block元素和inline元素差不多，但是它可以设置固定的高宽。</p>
<h3>none</h3>
<p>如果元素的display的属性值为none，那么这个元素将不会显示。<code>&lt;script&gt;</code>元素的display值就是none。这经常被用来控制一个元素的显示的隐藏（使用JavaScript）：</p>
<pre class="">document.getElementById("mask").style.display ='none';</pre>
<h3>display:none or visibility:hidden?</h3>
<p>display:none是隐藏一个元素，像是这个元素不存在一样。而visibility:hidden只是使元素不可见，<strong>元素仍然占据原有的空间</strong>。</p>
<p>&nbsp;</p>
<h2><a name="position"></a>二、Position</h2>
<p>有四种值（默认为static）：</p>
<pre class="">static 
relative 
fixed 
absolute</pre>
<h3>static</h3>
<p>position属性为static的元素的位置没有特殊效果。</p>
<h3>relative</h3>
<p>相对定位。这里的relative是指<strong>相对于正常的位置</strong>进行定位。可以设置top，right，bottom和left来偏移位置。</p>
<h3>fixed</h3>
<p>固定定位。<strong>相对于浏览器窗口来说是固定的</strong>，无论你怎么缩放窗口大小，或是滚动内容。可以设置top，right，bottom和left来偏移位置。</p>
<h3>absolute</h3>
<p>绝对定位。<strong>相对于最近的父元素</strong>（position值为static的元素除外）进行定位。可以设置top，right，bottom和left来偏移位置。</p>
<h3>z-index</h3>
<p>z-index属性用来指定一个元素在z轴上的位置，利用这个属性可以实现元素的重叠。如果不指定，在HTML文件里，代码位置靠后的元素会在上面。主要使用场景有： 1. 在图片上添加一个按钮，这时把按钮的z-index设置比图片大，就可以点击到按钮而不是图片。 2. 在图片上显示文字，只要把图片的z-index设为-1就可以了。</p>
<p>&nbsp;</p>
<h2><a name="overflow"></a>三、Overflow</h2>
<p>Overflow用来定义当元素的内容超过限定的范围后的显示方式。有四种值：</p>
<h3>visible</h3>
<p>默认值。超出的内容仍然显示。</p>
<h3>hidden</h3>
<p>超出的内容将被隐藏。</p>
<h3>scroll</h3>
<p>添加一个滑动条。（将同时添加水平方向和竖直方向的滚动条，即使不需要。）</p>
<h3>auto</h3>
<p>类似于scroll，不过只在需要的时候添加滑动条。</p>
<h3>overflow-x overflow-y</h3>
<p>这两个值用来分别定义两个方向的overflow值。</p>
<pre class="">div { 
    overflow-x: hidden; /* 隐藏超出内容 */ 
    overflow-y: scroll; /* 添加垂直滑动条 */ 
}</pre>
<h2> </h2>
<h2><a name="float"></a>四、Float</h2>
<p>float用来设置元素的滚动，像这样<code>float: left;</code>。一般的用法有：让文字包裹图片；制作navbar，让li元素向左浮动。</p>
<p>浮动的元素下面的元素会包裹住浮动的元素，这时可以用clear用来控制元素的滚动，下面这行让左边的元素不滚动：</p>
<pre class="">div { 
    clear: left; 
}</pre>
<h2> </h2>
<h2><a name="align"></a>五、Align</h2>
<ul>
<li>水平居中：使用<code>margin: auto;</code>（在IE8里需要声明!DOCTYPE）。这时要给元素限定宽度，比如<code>width: 50%;</code>，限定的宽度之外的空间会被一分为二。</li>
<li>垂直居中：使用padding属性可以让元素在父容器里垂直居中<code>padding: 50px 0;</code>。</li>
<li>文本居中：<code>text-align: center;</code>。</li>
<li>
<p>图片居中：</p>
</li>
</ul>
<pre class="">display: block; 
margin: auto;</pre>
<ul>
<li>
<p>居左或右：使用float。</p>
</li>
<li>
<p>水平+垂直居中：使用padding加上<code>text-align: center;</code>。或是使用position和transform：</p>
</li>
</ul>
<pre class="">.center { 
    height: 200px; 
    position: relative; 
    border: 3px solid green; 
} 

.center p { 
    margin: 0; 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
}</pre>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/css-note-layout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSShake——元素摇晃特效</title>
		<link>https://greyli.com/css-shake/</link>
		<comments>https://greyli.com/css-shake/#comments</comments>
		<pubDate>Sun, 20 Mar 2016 01:14:04 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://withlihui.com/?p=271</guid>
		<description><![CDATA[效果演示 所谓的摇晃特效，就是当你把光标移到文字上的时候……我可以轻微的晃，慢慢的晃，猛烈晃，疯狂晃，甚至左右 [&#8230;]]]></description>
				<content:encoded><![CDATA[<link rel="stylesheet" type="text/css" href="https://csshake.surge.sh/csshake.min.css">
<style>
.shake {display: inline-block !important}
</style>
<h2>效果演示</h2>
<p>所谓的<span class="shake-constant shake">摇晃</span>特效，就是当你把光标移到文字上的时候……我可以<span class="shake shake-little">轻微的晃</span>，<span class="shake shake-slow">慢慢的晃</span>，<span class="shake shake-hard">猛烈晃</span>，<span class="shake shake-crazy">疯狂晃</span>，甚至<span class="shake shake-horizontal">左右晃</span>，<span class="shake shake-vertical">上下晃</span>，<span class="shake shake-rotate">旋转着</span>，<span class="shake shake-opacity">闪烁着</span> ……</p>
<div class="shake shake-slow">
<div id="attachment_699" style="width: 310px" class="wp-caption aligncenter center"><a href="http://greyli.com/wp-content/uploads/2016/03/ass.gif" rel="attachment wp-att-699"><img class="wp-image-699 size-full" src="http://greyli.com/wp-content/uploads/2016/03/ass.gif" alt="摇晃的驴子" width="300" height="350" /></a><p class="wp-caption-text">光标移到驴子身上就可以摇晃它</p></div>
</div>
<p>前段时间在家没事做，突然想到之前看到的CSS特效，觉得文字摇晃很好玩。google了一下，原来是一个开源的css包。心血来潮，便想做个网页试一下。</p>
<p>下面是css shake的用法介绍，整理翻译自github页面的介绍：<br />
首先在html里声明包含css文件，最简单的方法是通过CDN加载（你也可以将https://csshake.surge.sh/csshake.min.css下载到本地然后加载）：</p>
<pre class="">&lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/csshake/1.5.3/csshake.min.css" /&gt;</pre>
<p>然后通过添加class来使用不同的效果：</p>
<pre class="lang:html decode:1">&lt;div class="shake"&gt;Foo&lt;/div&gt; 
&lt;div class="shake shake-hard"&gt;Bar&lt;/div&gt; 
&lt;div class="shake shake-slow"&gt;Baz&lt;/div&gt; 
&lt;div class="shake shake-little"&gt;Qux&lt;/div&gt; 
&lt;div class="shake shake-horizontal"&gt;Egg&lt;/div&gt; 
&lt;div class="shake shake-vertical"&gt;Ham&lt;/div&gt; 
&lt;div class="shake shake-rotate"&gt;Snake&lt;/div&gt; 
&lt;div class="shake shake-opacity"&gt;Apple&lt;/div&gt; 
&lt;div class="shake shake-crazy"&gt;Orange&lt;/div&gt;</pre>
<p>还可以通过增加class来控制动画的状态（比如一直摇晃，还是光标放上去摇晃）</p>
<pre class="lang:html decode:1">&lt;!-- Freeze the animation at that point when :hover --&gt; 
&lt;div class="shake shake-freeze"&gt;Hello&lt;/div&gt; 
&lt;!-- Continuous animation instead on :hover --&gt; 
&lt;div class="shake shake-constant"&gt;Hola&lt;/div&gt; 
&lt;!-- and stop when :hover --&gt; 
&lt;div class="shake shake-constant shake-constant-hover"&gt;Halo&lt;/div&gt;</pre>
<p>另外，还可以自定义摇晃类型，具体的用法请参考 <a href="https://elrumordelaluz.github.io/csshake/" target="_blank" rel="noopener">https://elrumordelaluz.github.io/csshake/</a></p>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/css-shake/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
