Transparent buttons with a unique shape and a border made up of small dots

Can a button be created with a transparent background and a dotted border, in a custom shape?

https://i.sstatic.net/YEMU2.jpg

Although I have successfully achieved this with a background color, I am facing difficulties trying to fill the inner part without any color.

body{
  background: #999
}
button {
  height: 50px;
  width: 250px;
  border: dotted 1px #FFF;
  border-bottom: none;
  background: none;
  position: relative;
}
button:after,
button:before {
    content: '';
    display: block;
    position: absolute;
    top: 100%;
    width: 0;
    height: 0;
    border-style: solid;
}

button:after {
    border-color: #fff transparent transparent transparent;
    border-width: 1px 125px 0 0;
    right: 1px
}

button:before {   
   border-color: transparent transparent #fff transparent;
   border-width: 0 125px 1px 0;
   left: 0
}
<body>
<button></button>
</body>

Answer №1

Instead of using a button, you can get creative and make shapes with div elements.

To achieve this, you need to play around with borders to form different shapes.

#triangle{
width: 0;
height: 0;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
border-bottom: 40px solid green;
}
<div id="triangle"></div>

In the example above, I've demonstrated how to create a triangle by manipulating border properties. The key is understanding that div borders are not straight lines but have wedge-shaped ends.

This should serve as a good starting point for your shape creation journey.

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

Ways to align a flex child in the middle depending on the width of the

I'm currently working on centering the navigation menu horizontally by aligning it with the width of the header tags using tailwind CSS. However, I've run into an issue where it only centers based on the navigation tags' width. <!DOCTYPE ...

Ensure that the pseudo element inherits the background color of its parent

My dilemma involves multiple pseudo elements connected to diverse parent divs, each with a unique background color. My goal is for these before and after pseudo elements to mimic the background color of their respective parent divs without the use of Jav ...

Minimize the gaps between items within a CSS grid design

I'm struggling with adjusting the whitespace between 'Job Role' and 'Company Name' in my grid layout. Here's a snippet of what I have: https://i.sstatic.net/l55oW.png The container css is set up like this: .experience-child ...

When rendering, HTML characters are not translated

My JavaScript code generates the following HTML structure: <div contenteditable="false" tabindex="0" class="ProseMirror"> <p> didn't project a significant increase</p> </div> When rendered in the browser, it shows the cha ...

Discover captivating visuals that effortlessly occupy the entire breadth, while gracefully encompassing a mere quarter of the total vertical space on the

It's become quite challenging for me to locate images that can occupy the entire width of a page while maintaining just 25% of the page height. Whenever I make adjustments to the image's CSS, it ends up appearing distorted because its width is di ...

Does Ext js have a monochromatic theme of blue running through everything

While the blue color may give off a nice office ambiance, it's important to have variety in the appearance of different applications. Is it simple to customize the look in ext js? ...

Prevent the background image from extending behind the header and footer sections

I am struggling with the formatting of a webpage that features a header and footer. Currently, my background image extends behind both the header and footer, cutting off approximately one-quarter of the top and bottom of the image. Below is the CSS code I ...

Targeting all children instead of just the odd ones when using `nth-child(odd)`

In the portfolio, I have a unique requirement where every odd entry should be reversed. These projects are generated dynamically from an array and passed into the component through props. To style it, I'm utilizing styled-components. However, I&apos ...

Ordering dynamically in AngularJS without relying on the second input variable

Check out my Codepen here (function(){ var app = angular.module('bars',[]); app.controller('BarController',function(){ this.bars = bars; }); app.controller('YearController',function ...

Mobile phone carousel glitch

I am encountering an issue with the Bootstrap v4.0 Carousel that I can't seem to resolve. Despite searching online for similar problems, I have not been able to find a solution, which is quite perplexing. Whenever I load a page on an iPhone, the caro ...

Wrapping a series of grids within a parent container to manage height effectively with grid960

Testing on the following browsers: Internet Explorer, Chrome, Firefox; Check out this example of an ideal layout in a PDF: Here is the link to the direct page: While Grid systems work well for width layout, I struggle with setting height constants. In ...

Achieve mobile responsiveness for search fields with Bootstrap 4

Attempting to center my search field using the code below did not yield a responsive result. On mobile, it remains right on top with the footer, unlike on desktop where I'd like to see some space between them. This discrepancy only surfaces in small ...

Exploring Molecular Structures with ThreeJS - Understanding the Mechanics of Double Bonds

Currently working with threejs and experimenting with the example found in this link: The challenge I'm facing is related to creating double bonds between grey and red spheres in the example. While I came across some resources suggesting ways to achi ...

Ways to showcase tooltip text for an unordered list item?

When creating an unordered list, each element's text corresponds to a chapter name. I also want to include the description of each chapter as tooltip text. The Javascript code I currently have for generating a list item is: var list_item = document.c ...

Stop menu items from shifting when focused

I've developed a mobile hamburger menu and attempted to adjust the padding to create space between the text and the borders. Here's the HTML: #menu-solutions:hover .menu-item-text, #menu-solutions:focus .menu-item-text, #menu-solutions:ac ...

The label and its .input-group in Bootstrap 5 are not aligned on the same line

<div class="input-group mb-3"> <label class="input-group-text form-floating ">Please Share Your Name *</label> <input type="text" class="form-control" placeholder="First Name&quo ...

What is causing my h2 and div elements to share the same font size?

I've been working on converting an element. The font-size conversion seems to be successful, but the margin conversion is not working as expected. Here is my code attempt: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &q ...

How can I ensure that a radio button remains checked when selecting a disabled option in Internet Explorer?

Encountering an issue in various versions of Internet Explorer (9,10,11): I have a group of radio buttons that need to be disabled but still submitted with the form. To achieve this, I devised a method using the following functions: var doNothing = functi ...

Unable to view images on Wordpress theme

I am currently facing an issue where some images in my asset folder are not displaying properly when I convert my HTML/CSS/JS template to Wordpress. The main problem is with the image that should show up when you first visit the website. Below is the CSS c ...

Tips for Achieving a Smooth Transition Effect with jQuery while Modifying an Image's Attribute

I am facing an issue with the code I have written to change the image source on mouse hover. While it does change the image src, the effect is quite jerky and abrupt. Is there a way to slow down the animation effect? <script> $(document).re ...