您的位置:

CSS Border Bottom常用属性详解

一、border-bottom的基本使用

   border-bottom: 单位 边框样式 颜色;

border-bottom是css中用来设置底部边框的属性。

border-bottom的属性值包括三个,分别是:边框宽度(单位),边框样式(solid、dotted、dashed等)和边框颜色(十六进制代码或rgb颜色值)。

以下是一个简单的应用实例:

    <div style="border-bottom: 2px solid #F08080; padding-bottom: 10px;">
        <p>这是一段有底部边框的文字信息。</p>
    </div>

效果如下图所示:

这是一段有底部边框的文字信息。

二、border-bottom常用属性介绍

1. border-bottom-style

   border-bottom-style: none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset;

border-bottom-style是用来设置边框样式的属性。

取值说明:

  • none:没有边框(默认)
  • hidden:同none,但是打印的时候依然会有边框。
  • dotted:点线边框
  • dashed:虚线边框
  • solid:实线边框(默认值)
  • double:双线边框
  • groove:3D向内凹陷边框
  • ridge:3D向外凸出边框
  • inset:3D向内凹陷边框
  • outset:3D向外凸出边框

2. border-bottom-width

   border-bottom-width: 1px|medium|thin|thick;

border-bottom-width是用来设置边框宽度的属性。

取值说明:

  • 1px:像素值
  • medium:默认宽度
  • thin:细线宽度
  • thick:粗线宽度

3. border-bottom-color

   border-bottom-color: color|transparent;

border-bottom-color是用来设置边框颜色的属性。

取值说明:

  • color:常用的颜色值或RGB颜色值
  • transparent:透明,不显示颜色

4. border-bottom-image

    border-bottom-image: url("border.png")|none|initial|inherit;

border-bottom-image是用来设置边框图片的属性。

取值说明:

  • url("border.png"):指定图片的路径
  • none:无图片,默认值
  • initial:默认值
  • inherit:继承父元素的属性

三、其他Tips

1. 边框不影响元素大小

注意:设置border-bottom-style并不会影响元素的大小,仅仅会在底部绘制出一条边框线并呈现所设置的样式。

2. 边框可以设置为虚线、点线、实线和双线等

border-bottom-style属性可以设置为虚线、点线、实线和双线等样式。

3. 禁止底部折叠

虽然默认情况下,不同元素之间的底部边框会折叠在一起,但是我们可以加入一个 "border-collapse: separate;" 的属性来避免这种情况。

以下是一个具有明显折叠的底部边框:

    <div style="border-bottom: 1px solid black; height: 50px;">
        <p>这是第一个div</p>
    </div>
    <div style="border-bottom: 1px solid black; height: 50px;">
        <p>这是第二个div</p>
    </div>

效果如图所示:

这是第一个div
这是第二个div

添加border-collapse属性后再试一次:

    <div style="border-bottom: 1px solid black; height: 50px; border-collapse: separate;">
        <p>这是第一个div</p>
    </div>
    <div style="border-bottom: 1px solid black; height: 50px; border-collapse: separate;">
        <p>这是第二个div</p>
    </div>
这是第一个div
这是第二个div

4. 底部边框圆角效果

我们可以使用border-bottom-left-radius(设置左下角的圆角效果)和border-bottom-right-radius(设置右下角的圆角效果)来实现底部边框的圆角效果。

以下是一个简单的应用实例:

    <div style="border-bottom: 5px solid #ccc; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; height: 50px;">
        <p>这是一段带有圆角底部边框的文字信息。</p>
    </div>

效果如图所示:

这是一段带有圆角底部边框的文字信息。

总结

css的border-bottom属性是用来设置元素底部边框的。border-bottom-style、border-bottom-width和border-bottom-color是设置边框样式、宽度和颜色的常用属性。我们还可以利用border-bottom-image来设置边框的图片属性。在实际应用中,我们可以通过border-bottom-style属性设置为虚线、点线、实线和双线等样式,也可以使用border-bottom-left-radius和border-bottom-right-radius来实现底部边框的圆角效果。同时,我们可以注意到边框不影响元素的大小,并且要避免边框折叠的情况,我们可以在父元素中使用border-collapse属性来解决问题。

CSS Border Bottom常用属性详解

2023-05-19
CSS Bottom属性详解

2023-05-19
深入理解border-bottom

2023-05-21
border-bottom属性的全方位解析

2023-05-21
详解CSS border-image属性

2023-05-20
CSS border color属性详解

2023-05-12
CSS Border 属性详解

2023-05-12
CSS属性列表及用法详解

2023-05-12
深入理解border-radius属性

2023-05-19
CSS的定位position属性详解

2023-05-12
详解CSS中的BorderStyle属性

2023-05-18
CSS Border in HTML

2023-05-12
CSS中的尺寸属性

2023-05-12
CSS的border-sizing属性使用指南

2023-05-12
CSS border-spacing 属性

2023-05-12
when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: ${item.id} [in template "article/detail/index.ftl" at line 48, column 106] ---- Java stack trace (for programmers): ---- freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...] at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134) at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:481) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:401) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:370) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:104) at freemarker.core.DollarVariable.accept(DollarVariable.java:63) at freemarker.core.Environment.visit(Environment.java:371) at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:321) at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271) at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:244) at freemarker.core.Environment.visitIteratorBlock(Environment.java:645) at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:108) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94) at freemarker.core.Environment.visit(Environment.java:335) at freemarker.core.Environment.visit(Environment.java:341) at freemarker.core.Environment.visit(Environment.java:341) at freemarker.core.Environment.process(Environment.java:314) at freemarker.template.Template.process(Template.java:383) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:332) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:266) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:220) at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:181) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:314) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1431) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1167) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1106) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at com.software.filter.HttpSpiderIdentifyFilter.doFilter(HttpSpiderIdentifyFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)