些元素默認帶有padding, 比如ul標簽。
*{margin:0;padding:0;}
讓所有的標簽內外邊距是都 0 ;
*的執行效率不高, 所以我們使用并集選擇器, 羅列出所有的標簽(不用背, 有專業的清除默認樣式的樣式表, 以利于今后學習)
當然, 以上的寫法是我們練習的寫法。
真正的工作我們如下寫法:
html, body, ul, li, ol, dl, dd, dt, p, h1, h2, h3, h4, h5, h6, form, fieldset, legend, img { margin:0; padding:0; }
最常用
做html5網站的時候,測試時候會發現在蘋果手機上會有一些問題,會發現html5網頁中的按鈕會被自帶的樣式給替換了。
如下:
手機設備下的界面
正常瀏覽器下的html5界面
要解決該問題需要加入一些css樣式,如下:
input[type="button"], input[type="submit"], input[type="reset"] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
們通常用富文本框編輯內容存在數據庫中,在做列表顯示數據的時候不想顯示原來的樣式,用自定義函數格式化html標簽即可。
自定義函數
alter function [dbo].[dropHtmlTag](@cont varchar(max))
returns varchar(max)
as
begin
--去掉style標簽
declare @stylecount int;
set @stylecount = charindex('<style>',@cont);
while @stylecount>0
begin
select @cont=replace(@cont, SUBSTRING(@cont,CHARINDEX('<style>',@cont),CHARINDEX('</style>',@cont)-CHARINDEX('<style>',@cont)+8),'');
set @stylecount = charindex('<style>',@cont);
end
*請認真填寫需求信息,我們會在24小時內與您取得聯系。