简体   繁体   English

边框颜色悬停效果问题

[英]Issue with border-color hover effect

I've tried to set a hover effect to an icon. 我试图将悬停效果设置为图标。 When the cursor gets closer to that icon, the border colour of that icon will display but it should be in half radius. 当光标靠近该图标时,该图标的边框颜色将显示,但应在半径的一半范围内。 In my case I don't know how to do that and also I don't know whats wrong in my code. 就我而言,我不知道该怎么做,也不知道我的代码有什么问题。 If anyone knows a way to achieve that, it will be very helpful for me. 如果有人知道实现此目标的方法,它将对我非常有帮助。
For your reference i have uploaded my expected output image here. 供您参考,我在这里上传了我的预期输出图像。 在此处输入图片说明

 .round-right-arrow { border-radius: 24px; background: white; width: 40px; height: 40px; border-color: transparent; } .roundbtn { background: none; position: relative; } .roundbtn::before, .roundbtn::after { content: ''; position: absolute; width: 100%; height: 100%; } .spin { width: 37px; height: 37px; padding: 0; } .spin::before { border: 2px solid transparent; } .spin:hover::before { border-top-color: #ec7f4a; border-right-color: #ec7f4a; border-bottom-color: #ec7f4a; border-left-color: #ec7f4a; transition: border-top-color 0.15s linear, border-right-color 0.15s linear 0.1s, border-bottom-color 0.15s linear 0.2s; } .circle::before, .circle::after { border-radius: 100%; } 
 <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> <div class="spin circle roundbtn"> <button class="round-right-arrow"> <i class="fa fa-arrow-right " aria-hidden="true"></i> </button> </div> 

Using transform:rotate(45deg) and remove right and bottom border 使用transform:rotate(45deg)并删除right and bottom border

 .round-right-arrow { border-radius: 24px; background: white; width: 40px; height: 40px; border-color: transparent; } .roundbtn { background: none; position: relative; } .roundbtn::before, .roundbtn::after { content: ''; position: absolute; width: 100%; height: 100%; transform:rotate(45deg); -webkit-transform:rotate(45deg); -moz-transform:rotate(45deg); } .spin { width: 37px; height: 37px; padding: 0; } .spin::before { border: 2px solid #f2f2f2; } .spin:hover::before { border-top-color: #ec7f4a; border-left-color: #ec7f4a; transition: border-left-color 0.25s linear, border-top-color 0.25s linear 0.1s; } .circle::before, .circle::after { border-radius: 100%; } 
 <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> <div class="spin circle roundbtn"> <button class="round-right-arrow"> <i class="fa fa-arrow-right " aria-hidden="true"></i> </button> </div> 

It seems that the following CSS determines where the border is shown: 似乎以下CSS确定了显示边框的位置:

.spin:hover::before {
  border-top-color: #ec7f4a;
  border-right-color: #ec7f4a;
  border-bottom-color: #ec7f4a;
  border-left-color: #ec7f4a;
  transition: border-top-color 0.15s linear, border-right-color 0.15s linear 0.1s, border-bottom-color 0.15s linear 0.2s;
}

Update it as below to prevent it from displaying t the top 如下更新以防止其显示在顶部

 .round-right-arrow { border-radius: 24px; background: white; width: 40px; height: 40px; border-color: transparent; } .roundbtn { background: none; position: relative; } .roundbtn::before, .roundbtn::after { content: ''; position: absolute; width: 100%; height: 100%; } .spin { width: 37px; height: 37px; padding: 0; } .spin::before { border: 2px solid transparent; } .spin:hover::before { border-top-color: #ec7f4a; border-right-color: transparent; border-bottom-color: transparent; border-left-color: #ec7f4a; transition: border-top-color 0.15s linear, border-right-color 0.15s linear 0.1s, border-bottom-color 0.15s linear 0.2s; } .circle::before, .circle::after { border-radius: 100%; transform: rotate(225deg); } 
 <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> <div class="spin circle roundbtn"> <button class="round-right-arrow"> <i class="fa fa-arrow-right " aria-hidden="true"></i> </button> </div> 

is that what you want ? 那是你要的吗 ?

 .round-right-arrow { border-radius: 24px; background: white; width: 40px; height: 40px; border-color: transparent; } .roundbtn { background: none; position: relative; } .roundbtn::before, .roundbtn::after { content: ''; position: absolute; width: 100%; height: 100%; } .spin { width: 37px; height: 37px; padding: 0; } .spin::before { border: 2px solid transparent; } .spin:hover::before { border-top-color: #ec7f4a; border-right-color: transparent; border-bottom-color: transparent; border-left-color: #ec7f4a; transition: border-top-color 0.15s linear, border-right-color 0.15s linear 0.1s, border-bottom-color 0.15s linear 0.2s; } .circle::before, .circle::after { border-radius: 100%; transform: rotate(225deg); } 
 <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> <div class="spin circle roundbtn"> <button class="round-right-arrow"> <i class="fa fa-arrow-right " aria-hidden="true"></i> </button> </div> 

added transparent color to border-top-color & border-top-color and used transform: rotate(315deg); border-top-colorborder-top-color添加了透明色,并使用了以下transform: rotate(315deg); to rotate it. 旋转它。 thanks 谢谢

 .round-right-arrow { border-radius: 24px; background: white; width: 40px; height: 40px; border-color: transparent; } .roundbtn { background: none; position: relative; } .roundbtn::before, .roundbtn::after { content: ''; position: absolute; width: 100%; height: 100%; } .spin { width: 37px; height: 37px; padding: 0; } .spin::before { border: 2px solid transparent; } .spin:hover::before { border-top-color: TRansparent; border-right-color: TRansparent; border-bottom-color: #ec7f4a; border-left-color: #ec7f4a; transition: border-top-color 0.15s linear, border-right-color 0.15s linear 0.1s, border-bottom-color 0.15s linear 0.2s; transform: rotate(315deg); } .circle::before, .circle::after { border-radius: 100%; } 
 <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> <div class="spin circle roundbtn"> <button class="round-right-arrow"> <i class="fa fa-arrow-right " aria-hidden="true"></i> </button> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM