开发CSS相关

本文探讨了HTML/CSS中的布局技巧,如背景图居中、表单定位、弹性布局和定位策略,还涵盖了精灵图、阴影效果、重复样式的简洁写法、伪元素和渐变背景的使用。关键词包括HTML、CSS、布局、精灵图、阴影和前端开发技术。
摘要由CSDN通过智能技术生成

开发

项目背景图

html,body{
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  /*不复制图片且图片居中*/
  background: url(..) no-repeat center;
  background-size: cover;
}

表单居中

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

居右布局

  display: flex;
  justify-content: flex-end;

子绝父相

固定布局

/* 固定定位根父级别没关系,屏幕为准 */
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  -webkit-transform: translateX(-50%);
  max-width: 540px;
  min-width: 320px;
  height: 44px;
  width:100%;
  background-color: pink;

精灵图

.my::before{
  width: 23px;
  height: 23px;
  content:"";
  display:block;
  background: url('../images/sprite.png') no-repeat -59px -194px;
  background-size: 104px auto;
  margin: 5px auto 0;
}

加影子

// 水平 竖直 模糊 程度
box-shadow: 0 2px 4px rgba(0, 0, 0, .2);

标签属性修饰

a{
  text-decoration: none;
}
div{
  box-sizing: border-box;
}
ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

重复样式的快捷写法

// 样式名字重复的部分写上
.local-nav li [class^="local_icon"] {
  width: 32px;
  height: 32px;
  margin-top: 8px;
  background-color: pink;
  background: url(../images/localnav_bg.png) no-repeat 0 0;
  //靠底部居中
  //background: url(../images/hotel.png) no-repeat bottom center;
  background-size: 32px auto;
}
.local-nav li .local_icon2 {
  background-position: 0 -32px;
}

文字阴影

  text-shadow: 1px 1px rgba(0, 0, 0, .2);

灵活运用伪元素

.nav-item a:nth-child(1){
  border-bottom: 1px solid #fff;
}
.nav-item:nth-child(1) a{
  border: none;
}

背景渐变

  background: -webkit-linear-gradient(left,lightblue,pink);

字体不显示

// 1.
text-indent: -999px;
// 2.
font-size: 0;

旋转箭头

.more::after{
  content: "";
  position: absolute;
  top: 9px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-top: 2px solid #fff;
  border-right: 2px solid #fff;
  transform: rotate(45deg);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值