html怎么让列表卡片半圆,css实现漂亮的卡片样式,半圆效果

css实现漂亮的卡片样式,卡券两端半圆缺口效果

最近项目中遇见了需要在矩形两端挖半圆的卡券设计,一般我们在设计飞机票、小票、火车票、卡券等这类卡片时,都可以用这种漂亮的半圆缺口样式,下面就让我们来看哈效果图和具体的代码吧!

样式效果:

e3c1cdcea4ee

下面一起来看看如何实现吧!

// An highlighted block

export default {

data(){

return{}

},

methods: {

}

};

.added-card{

width: 182px;

height: 244px;

background: #FFFFFF;

box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);

opacity: 1;

.added-card-footer{

position: relative;

width: 100%;

height: 48px;

border-top: 1px solid #EEEEEE;

.right-circle{

width: 20px;

height: 20px;

border-radius: 50%;

background: #FFFFFF;

position: absolute;

top: -10px;

right: -10px;

}

.right-circletop{

width: 10px;

height: 20px;

border-radius: 10px 0 0 10px;

background: #FFFFFF;

box-shadow: 2px 0px 3px rgba(0, 0, 0, 0.12) inset;

position: absolute;

top: -10px;

right: 0px;

}

.left-circle{

@extend .right-circle;

left: -10px;

}

.left-circletop{

@extend .right-circletop;

transform: rotate(180deg);

left: 0px;

}

}

}

至此,就这样愉快地实现啦!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
实现半圆效果可以通过自定义 View 来实现。 下面是一个实现的示例代码: ```java public class SemiCircleView extends View { private Paint mPaint; private RectF mRectF; private int mStartAngle; private int mSweepAngle; private int mStrokeWidth; private int mColor; public SemiCircleView(Context context) { this(context, null); } public SemiCircleView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SemiCircleView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SemiCircleView); mStartAngle = typedArray.getInt(R.styleable.SemiCircleView_startAngle, 0); mSweepAngle = typedArray.getInt(R.styleable.SemiCircleView_sweepAngle, 180); mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.SemiCircleView_strokeWidth, 10); mColor = typedArray.getColor(R.styleable.SemiCircleView_color, Color.RED); typedArray.recycle(); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(mStrokeWidth); mPaint.setColor(mColor); mRectF = new RectF(); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); int width = getWidth(); int height = getHeight(); mRectF.set(mStrokeWidth / 2, mStrokeWidth / 2, width - mStrokeWidth / 2, height - mStrokeWidth / 2); canvas.drawArc(mRectF, mStartAngle, mSweepAngle, false, mPaint); } public void setStartAngle(int startAngle) { mStartAngle = startAngle; invalidate(); } public void setSweepAngle(int sweepAngle) { mSweepAngle = sweepAngle; invalidate(); } public void setStrokeWidth(int strokeWidth) { mStrokeWidth = strokeWidth; mPaint.setStrokeWidth(mStrokeWidth); invalidate(); } public void setColor(int color) { mColor = color; mPaint.setColor(mColor); invalidate(); } } ``` 在布局文件中使用: ```xml <com.example.widget.SemiCircleView android:id="@+id/semiCircleView" android:layout_width="200dp" android:layout_height="100dp" app:startAngle="0" app:sweepAngle="180" app:strokeWidth="20dp" app:color="@color/colorAccent"/> ``` 然后在代码中动态设置属性值即可实现半圆效果
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值