visual editor - Insert wrap span tag around contents of a link tag automatically

I've searched around a good bit last night and today and haven't been able to find just what I'm looking

I've searched around a good bit last night and today and haven't been able to find just what I'm looking for here.

Basically I'm trying to automate this process:

When I click the link button inside the Wordpress visual editor I want to automatically wrap the contents with a span tag as well.

i.e. Instead of the output being...

<a href="#">This link</a>

...it would instead output:

<a href="#"><span>This link</span></a>

I have some link styles dependent on a span tag being wrapped around the link text and I don't want to manually edit every link whenever I add one.

Is this something that I can accomplish or do I have to use some JS or something to have it go through my post links and apply the change? The only links that need to be automated are links inside the articles.

Any insight is greatly appreciated.

EDIT: Here's the link style I'm trying to recreate:

Alternatively, if there's another way to do this style without the span tag then I'm all ears.

I've searched around a good bit last night and today and haven't been able to find just what I'm looking for here.

Basically I'm trying to automate this process:

When I click the link button inside the Wordpress visual editor I want to automatically wrap the contents with a span tag as well.

i.e. Instead of the output being...

<a href="#">This link</a>

...it would instead output:

<a href="#"><span>This link</span></a>

I have some link styles dependent on a span tag being wrapped around the link text and I don't want to manually edit every link whenever I add one.

Is this something that I can accomplish or do I have to use some JS or something to have it go through my post links and apply the change? The only links that need to be automated are links inside the articles.

Any insight is greatly appreciated.

EDIT: Here's the link style I'm trying to recreate: https://codepen.io/jacob_johnson/pen/ExYZgEV

Alternatively, if there's another way to do this style without the span tag then I'm all ears.

Share Improve this question edited Sep 25, 2019 at 19:34 Jacob Johnson asked Sep 25, 2019 at 19:16 Jacob JohnsonJacob Johnson 1011 bronze badge 2
  • If you could explain exactly the reason you need those span in the links for styling maybe someone could give you a solution that won't require the span in the first place. – freejack Commented Sep 25, 2019 at 19:27
  • codepen.io/jacob_johnson/pen/ExYZgEV I'm trying to achieve this link style which I could only figure out by inserting a span tag in my link tag. If there's a better solution I'd love to know. – Jacob Johnson Commented Sep 25, 2019 at 19:33
Add a comment  | 

1 Answer 1

Reset to default 1

The effect you are looking for can be achieved by adding the box-shadow to the link element directly. The span is totally unnecessary:

Just change this:

a {
  color: #545454;
  text-decoration: none;
}

a span:hover {
  color: #000000;
  box-shadow: inset 0 -10px #ffbe76;
}

a span{
  box-shadow: inset 0 -10px #f6e58d;
}

To this:

a {
  color: #545454;
  text-decoration: none;
  box-shadow: inset 0 -10px #f6e58d;
}

a:hover {
  color: #000000;
  box-shadow: inset 0 -10px #ffbe76;
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745129822a4612911.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信