doushang2023 2013-12-03 16:27
浏览 94

下划线延伸到单词的结尾,字母间距[关闭]

I am developing a WordPress site and have increased the letter-spacing on the sites navigation bar by adding letter-spacing: 4px; to the sites #mainNav ID located within the themes style.css file. I have also added text-decoration: underline; to the same style.css file under the following classes so that the currently viewed page will be underlined in the navigation bar:

#mainNav ul li.current a,
#mainNav ul li.current-cat a,
#mainNav ul li.current_page_item a,
#mainNav ul li.current-menu-item a,
#mainNav ul li.current-post-ancestor a,
.single-post #mainNav ul li.current_page_parent a,
#mainNav ul li.current-category-parent a,
#mainNav ul li.current-category-ancestor a,
#mainNav ul li.current-portfolio-ancestor a,
#mainNav ul li.current-projects-ancestor a {
    color: #2e2e2e;
    text-decoration: underline;
}

The problem is that because of the increased letter-spacing the underline projects beyond the end of the word.

I have seen the answers to CSS Text underlining too long when letter-spacing applied, but because the navigation bar is being pulled together by PHP it is not so easy as modifying the html for a static page, as is proposed in the answers.

The navigation bar in WordPress is constructed via the files nav-menu-template.php and nav-menu.php in the wp-includes folder. Could someone please provide assistance in how I may be able to implement some PHP into the navigation bar PHP so that it will automatically apply the letter-spacing to all letters minus the last?

  • 写回答

3条回答 默认 最新

  • doumei3828 2013-12-03 16:35
    关注

    Duplicated question: CSS Text underlining too long when letter-spacing is applied?

    That is the normal behaviour of letter-spacing, to accomplish what you want you need to remove the letter-spacing from the last character, check the correct solution of question above to more details.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c