Ensuring the custom button height matches the circumference of a circle:

My current project involves creating a circular interface with two buttons occupying one-third of its circumference.

Check out my progress here

The challenge I'm facing lies in aligning the height of the buttons perfectly within the parent circle.

Here's a glimpse at the HTML structure:

<div class="circle"> 
  <button class="button one"> Play </button>
  <button class="button two"> Pause </button>
</div>

And here's a snippet of the CSS involved:

.circle {
  width: 300px;
  height: 300px;
  border: 10px solid black;
  border-radius: 100%;
  position: relative;
}

.button {
  position: absolute;
  width: 145px;
  height: 100px;
/*   Attempts to adjust z-index affected clickability */
/*   z-index: -1;  */
}

.one {
  bottom: 0;
  left: 5px;
  border-radius: 0 0 0 100%;
/*   Tried hiding excess with added black border */
/*   border-left: 5px solid black */
}

.two {
  bottom: 0;
  right: 5px;
  border-radius: 0 0 100%;
/*   Added black borders for overlay issues*/
/*   border-right: 5px solid black; */
}

I've experimented with adjusting the height and adding borders, but perfect alignment still eludes me. The last resort was introducing a z-index property, which resolved the visual issue, albeit rendering the buttons unclickable.

If you have any suggestions on achieving that elusive perfection, your input would be greatly appreciated!

Answer №1

Have you attempted this solution? I've included overflow:hidden to the .circle class and removed the border-radius property from the buttons.

.circle {
  width: 300px;
  height: 300px;
  border: 10px solid black;
  border-radius: 100%;
  position: relative;
  overflow:hidden;
}

.button {
  position: absolute;
  width: 140px;
  height: 100px;
}

.one {
  bottom: 0;
  left: 10px;
}

.two {
  bottom: 0;
  right: 10px;
}

Answer №2

To eliminate the border-radius attribute from the buttons, simply include overflow:hidden in the parent div (referred to as the circle)

.circle {
  width: 300px;
  height: 300px;
  border: 10px solid black;
  border-radius: 100%;
  position: relative;
  overflow:hidden;
}

.button {
  position: absolute;
  width: 145px;
  height: 100px;
/*   Attempted to improve appearance by adding z-index to hide extra content, but now unclickable */
/*   z-index: -1;  */
}

.one {
  bottom: 0;
  left: 5px;
/*   Hiding excess content with a black border */
/*   border-left: 5px solid black */
}

.two {
  bottom: 0;
  right: 5px;
/*   Concealing additional content with a black border*/
/*   border-right: 5px solid black; */
}
<div class="circle"> 
  <button class="button one"> Play </button>
  <button class="button two"> Pause </button>
</div>

Answer №3

If you're faced with this design challenge, there are a couple of approaches you can take. One option is to meticulously align the buttons within the circle by adjusting their widths and border radius. Alternatively, you could explore the concept of hiding the buttons behind the circle using the pointer-events property as demonstrated below:

.circle {
  width: 300px;
  height: 300px;
  border: 10px solid black;
  border-radius: 100%;
  position: relative;
  z-index: 1;
  pointer-events: none; /* include this for magic */
  overflow: hidden;
}

.button {
  position: absolute;
  width: 140px;
  height: 100px;
   z-index: -1;  
   pointer-events: all; /* include this for magic */
}

.one {
  bottom: 0;
  left: 10px;
  border-radius: 0 0 0 100%;
}

.two {
  bottom: 0;
  right: 10px;
  border-radius: 0 0 100%;
}
<div class="circle"> 
  <button class="button one"> Play </button>
  <button class="button two"> Pause </button>
</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

Troubleshooting Flexbox Sticky Footer: Issue with 'Flex: 1' not properly filling the height

Currently experimenting with the flexbox sticky footer technique to create a dynamic-height footer, which has been a challenge for me. However, I'm facing an issue where the main section does not expand to fill the entire height of the window even aft ...

Choosing a unique font style in CSS (OTF) - How to differentiate between bold, italic, etc. when using multiple OTF files?

I'm a little confused on how to implement @font-face in my current project. The client handed over multiple font files including FontName-Black.otf, FontName-BlackItalic.otf, FontName-Bold.otf, FontName-BoldItalic.otf, and more. My usual approach wou ...

Is there a way to nest my form within another form and utilize just one submit button for both?

<form action="<?php $self ?>" method="post"> <h2>LundaBlogg</h2> <div class="fname"><label for="name"><p>Namn:</p></label><input name="name" type="text" cols="20" onkeyup="En ...

Enhance Your Website by Integrating Slick Slider with Bootstrap 4

I am currently facing a significant issue. I am attempting to integrate three div elements into my slider, and all of them maintain a Bootstrap 4 structure. The code looks like this, and it is being generated from another Jquery function where I am inserti ...

Load css and js files from a directory within Liferay

Is it possible to automatically load all CSS (or JS) files from a specific folder in Liferay 6.2? Below is an example of the liferay-portlet.xml file: <portlet> <portlet-name>Example</portlet-name> <icon>/icon.png</icon ...

How to Extract Minutes in Datatables Timestamps and Apply Custom Styling

Working with Datatables v1.10 Right now, my table is showing a date in the second column in the format 17-04-2019 14:34, which is how it's stored in the database. The filtering and searching functionality are all working as expected. The current HTM ...

Organizing an array of objects within MUI cards based on social media platforms

I'm currently developing an application that showcases athlete data in a grid layout using MUI Grid. The colored borders on the left side of each card are determined by the corresponding social network associated with that athlete. https://i.sstatic. ...

HTML Elements for Displaying Undefined JSON Information

Hey there, I'm new to programming and I'm looking to display JSON data in an HTML table using jQuery. The issue I'm facing is that the output from the server shows up as 'undefined'. My goal is to have a constantly updated list of ...

CSS - Absolute positioning appears to be slightly choppy in Microsoft Edge

I have successfully implemented a slip scrolling function to reveal/hide a fixed logo on scroll, but I am facing some issues with Microsoft Edge browser. While testing in various browsers, everything works smoothly except for Microsoft Edge. In this brows ...

Retrieve an HTML page rendering using C#

Is there a way to retrieve the exact HTML code from my website just as it appears in the browser? Initially, I attempted to use a web client like this: using (var client = new WebClient()) { var content = client.DownloadString("my_site_address"); } ...

What is the best way to display a multi-level sub-menu in front of its parent menu?

Code: nav#desktop-nav ul li > ul { position: relative; margin-top: 0; text-align: left; opacity: 0; visibility: hidden; position: absolute; top: 100%; transform: scaleY(0); transform-origin: 0 0 0; transition: al ...

Error message: ASP.Net Update Panel unable to access global variables in code-behind

I have been working on updating a bootstrap progress bar's percent on my website. While I understand that ajax is the recommended method for this, I attempted to achieve this without using ajax and was able to make some progress. Below is the code sn ...

Adding elements to a JavaScript array from within a PHP loop

I'm working with a php loop that is outputting geolocation values. I want to save these values in a javascript array so that I can use them to plot points on an HTML5 canvas. How can I achieve this? Here is the php loop: <ul id = "geo-list"> ...

Add a space following each individual character using CSS styling

Imagine we start with this HTML: <h2>TITLE</h2> Can CSS alone transform it into something like this: <h2>T I T L E</h2> The goal is to justify the letters within the title over a specified width without relying on server-side so ...

Enable drawing on a div element and synchronizing it across multiple divs using Javascript and HTML5

I am embarking on a project to create a website that allows users to doodle on an element and share it with others viewing the page using ajax - essentially a small-scale whiteboard feature. While I have a good grasp of HTML, CSS, Javascript (specificall ...

Learning to retrieve specific properties from an event target in JavaScript

Here is the code snippet I am working with: <h1 msgId = "someId"> Some text </h1> And in my code.js file, I have the following function: document.addEventListener('click', function(e) { target = e.target; }, false); I am tryin ...

placing a div inside another div

As I work on my website, I have created several panels with a repeating texture. To enhance the visual appeal of the site, I decided to add colored divs and adjust opacity for a tint effect instead of using separate images. The issue I'm facing is th ...

Saving game data from local storage to populate the player leaderboard

I have successfully developed a game in which users can play and their scores are stored locally. However, I am facing a challenge in figuring out how to showcase the scores of all users in a table on the Rankings page. Player Ranking Page <?php inclu ...

Can the unquoted HTML literal string syntax from scalatra be implemented in sinatra?

Is it possible to utilize this style in sinatra? get("/") { <html> <body> <h1>Hello, world!</h1> Say <a href="hello-scalate">hello to Scalate</a>. </body> </html> } I'm unsure i ...

The combination of Netbeans 8.0.1 and PhoneGap 3.5.0 is a powerful duo

My system is currently running Netbeans 8.0.1 and PhoneGap 3.5.0, but I am facing an issue where Netbeans does not allow me to create a new PhoneGap/Cordova project. According to some sources, this could be due to PhoneGap changing its versioning format, ...