关于h5网站常用的样式设置

1.文字镂空:

-webkit-text-fill-color:transparent;   
-webkit-text-stroke:1px #000;  

2.文字强制换行:

word-break: break-all; 

3.保留换行符。

// css保留空格和换行符

white-space: pre-wrap;

// css保留换行符

white-space: pre-line;

4.图片变灰色

   -webkit-filter: grayscale(100%);
    -moz-filter: grayscale(100%);
    -ms-filter: grayscale(100%);
    -o-filter: grayscale(100%);
    filter: grayscale(100%);
    filter: gray;
    opacity:0.7;

5.inp修改提示字的颜色

input::-webkit-input-placeholder {
	color: red; 
}

6.文字渐变色:

 p{
      background-image: linear-gradient(135deg,red,blue);
      -webkit-background-clip:text;
       color: transparent;
 }

<span text='房屋租赁到期提醒'>房屋租赁到期提醒</span>

 span{
	 position: relative;
        color:#ffd901;
}
 span:before{
        content: attr(text);
        position: absolute;
        z-index: 10;
        color:#ffff00;
        -webkit-mask:linear-gradient(to left, #ffff00, transparent );
    }


7.设置背景图固定在底部,不会跟随滚动条的变化而滚动

background-attachment: fixed;

background-image: url('图片路径');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 50%;
background-position: bottom;

8.h5页面跳转传参

window.location.href = 'list.html?name='+name+'&age='+age;

9.h5网页右上角的logo

<link rel="shortcut icon" href="/favicon.ico" />

10.响应式手机端图片:

图片设置:max-width:100%; max-height:100%;

11.css去除input聚焦时的边框:

input{  outline: none; }

12.手机端的logo在电脑端审查元素时是清晰的,在手机查看就模糊:

解决方法:宽高使用三倍像素的logo图片,使用时用1倍的宽高即可。

13.文本域textarea去掉边框的方法:

border:none; resize:none;

14.宽高未知的元素居中:

position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);

15.父元素高度随子元素变化而变化

#menu{width:1000px;overfloat:hidden;}  
.news_detail .img_div img{
	width: 100%;
	display: block;
	height: auto;
	overflow: hidden;
	margin: auto;
}  

16.iframe实现将超链接内容显示到当前页面:

<iframe src ="https://720yun.com/t/97vkcy197dw?scene_id=69125726" longdesc="w3school.txt"></iframe>	

17.用swiper轮播的时候,新闻列表处,不要加loop:true;不然只有一条新闻的时候,会显示多条。

18.css给图片增加模糊效果:

只要在图片里面添加一个CSS即可:filter: blur(10px);

19.网站轮播图,宽度设置为100%的时候,会有模糊的感觉。使用object-fit属性可以解决。

tips:object-fit 属性指定元素的内容去适应指定容器的高度与宽度。
代码:img{ width: 100%; object-fit: none; }

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值