Section of links spanning 4 columns in full-width

Planning to design a 4 column link section for an upcoming website, aiming to achieve the look in the provided screenshot.

https://i.sstatic.net/pydBp.png

Each box will serve as a clickable link, changing color on hover. Utilizing the Bootstrap framework for this project.

Considered using images for each box, but concerned about potential slowdowns on page load. Any suggestions on how to incorporate background images instead?

Open to ideas from the community - looking forward to your input!

Answer №1

Check out this straightforward example I made using only CSS. Don't forget to review the comments within the code.

.elements {
  display: flex;
  width: 100%;
  height: 50px;
}

.elements .element {
  flex: 0 0 25%;
  background-color: blue;
  position: relative;
  display: flex;
}

.elements .element a {
  
  padding-left: 30px; /* Ensures the triangle doesn't overlap the text */
  color: white;
  margin: auto 0;
}

/* The last element will not have the triangle shape */
.elements .element:not(:last-child)::after {
  content:"";
  position:absolute;
  border-left:15px solid blue; /*Set your preferred arrow color here*/
  border-top:25px solid transparent; /*half the height (50px)*/
  border-bottom:25px solid transparent; /*half the height (50px)*/
  right:-15px; /*Position it on top-right, overlapping with the next element*/
  top:0;
  z-index: 1;
}

/* Selects every second element for automatic color variation */
.elements .element:nth-of-type(2n) {
  background-color: green;
}

.elements .element:nth-of-type(2n)::after {
  border-left:15px solid green;
}
<div class="container">
  <section class="elements">
    <div class="element">
      <a href="#">
        Element 1
      </a>
    </div>
    <div class="element">
      <a href="#">
        Element 2
      </a>
    </div>
    <div class="element">
      <a href="#">
        Element 3
      </a>
    </div>
    <div class="element">
      <a href="#">
        Element 4
      </a>
    </div>
  </section>
</div>

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

What is the best way to trigger a function once another one has finished executing?

After opening the modal, I am creating some functions. The RefreshBirths() function requires the motherId and fatherId which are obtained from the getDictionaryMother() and getDictionaryFather() functions (these display my mothers and fathers on the page s ...

The output in the window will display the result of doubling the input box value, not the div

Can someone help me figure out why my code isn't working as expected? I'm trying to create a text box where you can enter a number, click a button, and it will multiply the number by two and display the result. However, right now, the code opens ...

How can an input field with a checkbox type be properly placed within a table data tag in a table nested within an AngularJS modal?

Below is the code for my modal: <!-- modal for viewing permissions --> <div id="modal-user-permissions" class="modal"> <div class="modal-content"> <h4 id= ...

Are HTML's Regular Expressions the Equivalent of JavaScript's Regular Expressions?

I have been trying to utilize the pattern="" attribute in HTML to implement regex, but unfortunately, I am unable to locate a comprehensive list of HTML regex parameters. This has led me to ponder whether the syntax for regex in HTML is similar to JavaSc ...

Align the items in the center of a Bootstrap navigation bar

I am looking to center the navigation menu items on my navbar. Currently, my navbar layout appears like this: https://i.sstatic.net/BqRwW.png Specifically, I want "Users", "Admin", and "Records" to be centered within the navbar. Additionally, I would lik ...

haphazardly showcase circular shapes within a confined space

Is there a way to display circles randomly inside a box without them extending beyond the box or touching its corners? Can the circles be plotted using relative values (percent) within the div? For example, can a circle be placed 10% from the left side and ...

The Javascript document refuses to load

I am currently working on a website with the main file named index.html: <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Title</title> </head> ...

Breaking a line within a list item will create additional spacing between the lines

Is there a way to break a line <br/> inside a <li> tag? For example: First line second line Second list item Third list item I've tried setting margin and padding to 0, but I still get an unwanted space between the lines. Any suggesti ...

Exploring mysterious traits through inheritance

In my Angular and TypeScript project, I have defined an interface: export interface A { name: string; } Now I have two other interfaces that inherit from interface A: export interface B extends A { year: number; } export interface C extends A { ...

Is it true that by utilizing Vue's v-for, every line of HTML code becomes a

I'm struggling to utilize v-for in order to create multiple div elements, but no matter how I attempt it (even trying to iterate over a list), the v-for doesn't seem to function properly and always turns the line into a comment when executed. No ...

Bx slider - displaying partially hidden slides at the far right while utilizing a full-width carousel

Implementing a slider on my nodejs website using bx slider has been quite an experience. Below is how I achieved it: $(document).ready(function(){ $(".bxslider").bxSlider({ minSlides: 1, maxSlides: 40, slideWidth: 300, ...

Ways to define css attributes for the "before" and "after" pseudo elements in the DOM

I'm looking to modify the color of the "border-left" property from its default red to a different color within the scope, such as blue. .hello:before { content:' '; display:inline-block; width: 22px; height: 25px; ...

How can I style an image in CSS to have a set height, maximum width, and keep its aspect ratio fixed?

I am trying to place a set of images with varying heights and widths inside a div tag. My goal is to have the images maintain a fixed height, unless the width surpasses a certain limit, in which case I want the height to adjust while preserving the aspect ...

Facing a problem with expanding the Bootstrap4 navigation menu

My code is as follows: <div class="container"> <nav class="navbar navbar-expand-md navbar-light bg-faded" id="menutop"> <button class="navbar-toggler navbar-toggler-right" type= ...

Modify the location of the input using jQuery

Hey there, I've got this snippet of HTML code: <div class='moves'> <div class='element'><input type='text' value='55' /></div> <input class='top' type='text&apo ...

Tips for displaying Japanese characters followed by numbers in a single line on a web browser using CSS

Combining Japanese characters with numbers without spacing can present formatting challenges. For example, with a string like "新しいフォルダ000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ...

Connecting mysql workbench data using html: A step-by-step guide

I'm currently creating a user interface for a database system using HTML. I'm a bit stuck on how to access and manipulate the database in MySQL Workbench. Does anyone have any suggestions or sample code that could help me connect them? Thanks! ...

Tips for implementing events with AngularJS Bootstrap Colorpicker

I am having trouble understanding how events function with Angular Bootstrap Colorpicker. I have forked a Plunker from the developer's example. Unfortunately, there are no examples provided for using events. It would be great if events like colorpick ...

Align the number of an Unordered List to the left

Exploring UN-ordered lists in HTML has led me to wonder if it's possible for dynamically generated ul tags to display like this: * Hello * Hi * Bi * Name * Ron * Mat * Cloth * Color * Red When I ...

Having trouble with Bootstrap not hiding on small screens as intended?

I'm not sure if the issue is related to my browser, but I need the first pills-tab to be hidden on small screens and visible on medium to larger screens. The second pills-tab should be visible on small screens and hidden on larger screens. <!D ...