how set border-bottom only for any divs

border-bottom length
css border-bottom only
border-bottom-width
border-bottom: none
border-bottom-color
border-bottom padding
border-bottom radius
border-bottom bootstrap

I have problem with set border-bottom

I have sth like this..

<article>
  <a></a>
  <div></div>
  <div></div>
</article>

But counter divs in article is variable. I need border-botom on div only when other div follow. So when I have one div, no border needed. When I have two divs, only first div have border. When I have three divs, only first and second has border... How I can do it?

article div:not(:last-of-type) {
  border-bottom: 1px solid #FFFFFF; /* or whatever you want */
}

CSS border-bottom property, Set the style of the bottom border for different elements: h1 { border-bottom: 5px solid red; } h2 { border-bottom: 4px dotted blue; } div { border-bottom: double; }. Specifies the width of the bottom border. Specifies the style of the bottom border. Specifies the color of the bottom border. Sets this property to its default value. Inherits this property from its parent element.

If I understood you correctly this is what you are trying to achieve:

HTML

<article>
  <a></a>
  <div>First</div>
</article>

<article>
  <a></a>
  <div>First</div>
  <div>Second</div>
  <div>Third</div>
</article>

<article>
  <a></a>
  <div>First</div>
  <div>Second</div>
  <div>Third</div>
  <div>Fourth</div>
</article>

CSS

article{
  margin: 20px;
}
article div{
  border-bottom: 1px solid red;
}
article div:last-of-type{
  border-bottom: none;
}

Relevant part:

article div:last-of-type{
  border-bottom: none;
}

CSS border-bottom-style property, Example. Set a style for the bottom border: div {border-bottom-style: dotted;}. Try it Yourself ». More "Try it Yourself" examples below. How to overlay one div over another div without using position: absolute? absolute for any of divs. menu who's initial li used a border-bottom:4px to create a

If you have only divs, you may just check for being the last child or last of type:

div {
    border-bottom: 1px solid #000;
}
div:last-of-type {
    border-bottom: none;
}

If you have divs and other elements and want borders only between divs, then I'd suggest using border-top instead and the + combinator (adjecent sibling selector):

div + div {
    border-top: 1px solid #000;
}

Unfortunately it matches only the following div, and not the followed one, thus border-top use.

border-bottom, The border-bottom shorthand CSS property sets an element's bottom border. div { border-bottom: 4px dashed blue; background-color: gold;  How to make borders collapse (on a div)? By the way there maybe variable number of cells in a column so I can't only have borders on one side. Set divs with

Hum. Think out the box. Try to fix a border-top on the next div just after a div ?

article div + div {
  border-top: 1px solid red;
}

maybe ?

border, The border shorthand CSS property sets an element's border. div { border: 0.5​rem outset pink; outline: 0.5rem solid khaki; box-shadow: 0 0 0  The border-right property is a shorthand property for (in the following order): border-right-width; border-right-style (required) border-right-color; If border-right-color is omitted, the color applied will be the color of the text.

CSS: border-bottom property, In this CSS border-bottom example, we have set the line style of the bottom border of the <div> tag to solid. You must set the style or the bottom border will not  There is only one limitation. You must set the height of the footer div to something other than auto. Choose any height you like, but make sure the value is specified in pixels or ems within your CSS. This is not a big limitation, but it is essential for this method to work correctly.

Creating a Body Border, #Technique #1: Four Divs I use the b tag borders because it's just visual stuff with no meaning so I may as well Some properties are shared by all of the elements, some by only the top/bottom and left/right, and some unique to themselves. @Dejan: You can get it to LOOK right with one div with a border, just set each of  The border-color property may be specified using one, two, three, or four values. When one value is specified, it applies the same color to all four sides . When two values are specified, the first color applies to the top and bottom , the second to the left and right .

Border Width, Utilities for controlling the width of an element's borders. .border-2 , .border-4 , or .border-8 utilities to set the border width for all sides of an element. .border-0 .​border .border-2 .border-4 .border-8. <div class="border-0 border-gray-600 . For example, use md:border-t-4 to apply the border-t-4 utility at only medium screen  You can give any element “rounded corners” by applying a border-radius through CSS. You’ll only notice if there is a color change involved. For instance, if the element has a background-color or border that is different than the element it’s over.

Comments
  • Thank you very much. This is exactly the selector I need