Switch to hexagonal bootstrap indicator shape

Is it possible to style a bootstrap indicator as a small hexagon?

I managed to style it as a rectangle, but I can't seem to get it to display as a hexagon.

Link to JS Fiddle

Here's what I attempted: http://jsfiddle.net/bn6aA/53/

CSS:

.carousel-indicators li {
  background-color: #4f3212;
  width:20px;
    border-radius: 0px;
}


.carousel-indicators .active {
  background-color: #999;
    width:20px;
    border-radius: 0px;
}

Answer №1

To style hexagon indicators in CSS, you can use the following code:

Adjusting Icon Size

.carousel-indicators {
    left: 0;
}

.carousel-indicators li {
    width: 24px;
    height: 15px;
    background: red;
    position: relative;
    line-height: 0;
    margin: 0 20px 0 0;
    padding: 0;
    border: 0;
    border-radius: 0;
}

.carousel-indicators li:before {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 10px solid red;
}
.carousel-indicators li:after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 10px solid red;
}
/*Active*/
.carousel-indicators li.active {
    background: gray;
}
.carousel-indicators li.active:before {
    border-bottom-color: gray;
}
.carousel-indicators li.active:after {
    border-top-color: gray;
}

You may need to adjust the size and position of the hexagons on your slider based on your preferences. The code provided here is a starting point. I utilized this resource for creating hexagons and you can view the updated Fiddle here. I hope this information is helpful.

Additional Note: To make the icons smaller, you will need to modify the width, height, and border properties of the .carousel-indicators li, as well as adjust the positioning values of .carousel-indicatorsli:before and .carousel-indicators li:after. You also have to tweak the top and bottom positions accordingly. See here for an updated Fiddle.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When hovering, the :after element will transition to the current div

How can I make the pink color div move vertically in front of the currently hovered div when we hover on it? Any suggestions on how to achieve this effect? https://i.sstatic.net/yfwgf.png $(document).ready(function() { $(".timeline-entry").hover(fu ...

Prevent the influence of other page styles on a div element

My question involves a browser extension that inserts a div element (along with others) into the page. Is there a method to prevent the page's styles from impacting the appearance of the elements I've added? One option I've thought about is ...

What is the best way to choose an item from one div and place it into another?

I am attempting to select an anchor from one div to another using jQuery functions such as next(), siblings(), parents(), parent(), and more. Below is an example of the HTML structure: <div class="thumbs"> <div class="section"> <d ...

What is the best way to remove the hover effect from a specific element within a div?

I am looking to achieve a specific hover effect where the white part does not darken when hovering over a certain element within its child elements. Here is the HTML code I have: <div className= {css.searchBarDiv}> <div className={css.searchBar ...

CSS - Ensuring the alignment of divs in columns

I attempted to find the information I needed, but all the results were related to CSS for internal divs. However, my goal is to have two columns of divs aligned next to each other, with the right column always positioned at the top of the left column. I&a ...

Best practice for incorporating Bootstrap into Webpack

Greetings everyone, I've been experimenting with Bootstrap for Webpack, but I've hit a roadblock. After reading numerous blog articles, I found that they either rely on the outdated 'bootstrap-webpack' plugin from 7 months ago (which d ...

Exploring a List of Divisions Based on User Input

My input field has a special functionality - Pressing the down arrow key will shift focus from the input to the first element in the list of divs below it, moving downwards as you continue pressing the down key. Pressing enter will set the text in that div ...

Looping through required fields in jQuery based on a CSS class

Is there a way to loop through required fields marked with <input class="required">? Currently, only the first input in the loop is being evaluated. How can I traverse the DOM using a loop to check all input boxes? Thank you for your help. While I ...

Modify the Div background color by accessing the HEX value saved in a JSON file

(I made a change to my code and removed the br tag from info2) Currently, I have successfully implemented a feature using jQuery that reads color names and hex values from a JSON file, populates them in a drop-down select menu (which is working fine). Now ...

Steps to reveal a concealed div when a button is pressed and hide the button in Angular 2

Having trouble with Angular UI development, particularly with the following requirement: When the Add Button is clicked, a hidden form should be displayed. Clicking the Add Button should also hide it. The hidden form includes a Cancel button. If Cancel i ...

Tips on condensing lengthy text into a single line using Bootstrap 4

I have been searching for a way to truncate long text into a single line in bootstrap 4. I have come across several solutions on Stack Overflow such as Link 1, Link 2, Link 3, but none of them seem to work for me. Here is the text I am dealing with: http ...

Change the styling of a DIV depending on the character count of a text within another DIV using JQuery

My website contains a series of div elements that display an image, title, and excerpt. Some of the content divs have titles that span two lines, while others have shorter one-line titles. I would like to add a different class to the excerpt div if the tit ...

At what point can we rely on the accuracy and timeliness of Element.getBoundingClientRect?

I am currently in the process of developing some code that utilizes Element.getBoundingClientRect (gBCR), combined with inline style updates, to carry out calculations. This particular project is not intended for a general website, so I am not interested i ...

What is the best way to use a CSS selector to target multiple divs such as block-11, block-12, and so

Here are several block IDs I have: <div id="block-11">content Here</div> <div id="block-12">content Here</div> <div id="block-13">content Here</div> <div id="block-14">conten ...

Issue with ASP.NET Form Input - Width behaving differently than expected (not expanding to 100%)

Simple Form Issue: Problem: The width of the <input> element is not expanding to 100% If the class form-control is applied to the element, it should have a width of 100% Screenshot: Output from Visual Studio Utilizing Visual Studio 2017 (MVC5 AS ...

Choose a div using jQuery and activate a hidden div

Seeking assistance in creating an interactive infobox that appears when hovering over a related image. Currently, the infobox pops out and flashes, but there is a problem where it shifts away from the image during the hover. I attempted to only display th ...

Navigating on the horizontal axis within a container with overflow properties

I am trying to insert multiple children-divs into a parent-div. The parent div has a fixed width. The children are set to float left and will overflow the container. I need the ability to scroll along the x-axis. However, when I attempt to do this, the c ...

Is there a way to ensure that the text is positioned below the image with flexbox?

https://i.sstatic.net/c5xyr.png Is there a way to make the text fall underneath the image? I am familiar with using display: inline-block and float:left or float:right, but I am new to using flexbox. Can someone with more expertise help me solve this issu ...

Displaying content on the <div> element

Looking for recommendations for a jQuery plugin or JavaScript solution that allows me to load a full "view" into a <div> when a user clicks on a link. The challenge I'm facing is that I have 8 pages, with the Homepage consisting of 3 divisions: ...

Can someone show me how to position this button within a React component onto the card that I've just made?

After successfully creating a Button component with separate JS and CSS files for styling variations, I am facing an issue where the button instance added to an advert card is not moving up as intended. Upon inspection, it seems that the button in the adve ...