Create curved edges for the divs inside other divs

I am currently working on creating rounded corners for my responsive table using div elements. However, I am encountering an issue where the top part of the div is not being rounded as expected.

Here is a preview of my current progress: https://i.sstatic.net/bpj8D.png

If you want to see the full code, you can check it out here: http://jsfiddle.net/ajt98kqy/

This is the structure of my HTML:

<div class="coltable">
<div class="col">
    <h4>Name</h4>
    <p>John</p>
</div>
<div class="col">
    <h4>Title</h4>
    <p>Manager</p>
</div>

My goal is to have rounded corners on all sides (the top border is currently not rounded). How can I go about fixing this issue?

Answer №1

Your inner content is spilling out and easily seen. To fix this, you should include the CSS rule overflow: hidden.

Here's how your code should look:

.coltable {
....
overflow: hidden;
}

By doing this, regardless of how much content you add, it will always remain contained within the confines at the top and bottom.

Answer №2

To make the h4 element rounded based on its column, you can modify the CSS like this:

.coltable .col h4 {
    margin: 0;
    padding: .75rem;
    border-bottom: 2px solid #dee2e6;
    background-color: blue;
    padding-left: 40px;
    color: #fff;
    border-radius: 10px 0 0 0; /* include this line in your code */
}

.coltable .col:last-child h4 {
  border-radius: 0 10px 0 0;
}

The values in the border-radius property represent each corner of the element, starting from the top left and going around clockwise.

I specifically targeted the last column using the last-child pseudo-class so that the styling will still apply even if you add an additional column.

You can see these changes in action in the updated fiddle here: http://jsfiddle.net/ajt98kqy/3/

Answer №3

To achieve rounded corners in Bootstrap 4, simply add the "rounded" class to your div element.

For example: "<div class="coltable rounded">

If you are not using Bootstrap 4, you can still create rounded corners with the CSS property "border-radius." Here are two ways to do it:

Inline Styling:

<div class="coltable" style="border-radius: 5px;">

External Styling:

In your CSS file:

.rounded{
    border-radius: 5px; // This will round every side of your border.
}

In your HTML file:

<div class="coltable rounded">

If you opt for external CSS, remember to link to your stylesheet in the <head> tag of your document:

<link rel="stylesheet" href="path/to/file/nameofcssfile.css">

Answer №4

To prevent overlap, include the CSS rule overflow: hidden; in the .coltable class.

The elements styled with the .col class are currently overlapping those within the .coltable 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

How to create interactive SVG animations on hover

Currently, I have successfully animated an SVG file using the default svg functions like the following: <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 16 30" ...

Problem with delaying in Jquery's .each method

I'm currently working on a JavaScript project and encountering some issues. Below is my HTML code: <div class="views-row"></div> <div class="views-row"></div> <div class="views-row"></div> <div class="views-row ...

Generate a responsive list with a pop-up feature under each item (using Vue.js)

Currently, I believe that Vue may not be necessary since most tasks can be done using JavaScript and CSS. I am attempting to design a list layout as follows: [A] [B] [C] [D] When an item is clicked, the information about that specific item should ...

Change the destination of an iFrame upon user click

Is it possible to redirect an iFrame to a different HTML page when clicked by the user? I have an iFrame that is essentially an HTML page. When I click on the iFrame, I want it to take me to another HTML page. This is my code: h1 { ...

Adding a linear gradient with a fade effect to Highcharts sparkline chart: Step by step guide

I am working with a Highcharts sparkline chart, and the design in my Figma file resembles the image provided below. I would like to customize the chart by adding transparency and a linear-gradient effect. Can anyone provide guidance on how to achieve this? ...

The min-height property in Bootstrap 3 causes a div element to not expand as expected

Having a bootstrap 3 page with a centered box that contains content, I noticed that the box does not expand when the content grows. The bootstrap container grows, but the box remains static. I have tried using "position:relative" and "overflow:hidden", as ...

Tips for aligning the child elements of a dropdown menu to stick with the parent's top position

It's important that progress and my goals are clearly outlined here: View my CodePen When it comes to the "Offices" section, I need the child objects to display directly below and ideally match the width of the parent element. Here is the code snip ...

Sequence of HTML elements arranged in a stack

Recently, I came across a useful jQuery tutorial called "jQuery for Absolute Beginners: Day 8". In this tutorial, there is an interesting code snippet that caught my attention: $(function() { $('.wrap').hover(function() { $(this).childre ...

Modify the color of the chosen value on the sidebar using Angular 6

I am looking to update the color of the selected value in the sidebar. Sample <div class="card c-setting"> <div class="card-header" title="Data Uploader"(click)="clickDataloader()"> <a class="card-link" data-toggle="collapse" href="# ...

Vue component always renders a new line

Whenever I include a <component> tag in my main application, it always renders on a new line. Is there a way to make it inline? I am trying to achieve something like this: <p>This is a component :<component></component></p> & ...

The steps to properly load "child.vue" into the correct position within "parent.vue" are as follows

Currently I am developing a single page web application using Vue.js. This app consists of 4 "page.vue" files, each with a right and left child .vue component nested inside. For instance, the Page1.vue file is structured as follows (omitting style and scr ...

Using Bootstrap CSS and JavaScript specifically for carousel functionality

Custom Styles and Scripts for Bootstrap Carousel Using Carousel with Controls https://getbootstrap.com/docs/4.0/components/carousel/ <div id="carouselExampleControls" class="carousel slide" data-ride="carousel"> <div class="carousel-inner ...

Navigating Django's Pagination feature alongside nested tabs requires a combination of careful planning

I am in the process of enhancing my template by adding pagination functionality. The template consists of Nested Tabs, each containing a table. My goal is to implement pagination for all tables within the inner tabs. Currently, I have successfully added p ...

The functionality of JQuery fails to work properly when receiving an AJAX response

I have separated my code into three main sections: a PHP file, a jQuery section with an AJAX function that requests data, another PHP file. The response from the AJAX request is HTML that needs to be added at the beginning of a specific DIV inside the i ...

Endless rotation with stunning magnification feature

My goal is to create a responsive carousel with auto-play infinite loop functionality, where the center item always occupies 70% of the viewport width. Currently, I have achieved a similar result using the Slick library: https://codepen.io/anon/pen/pBvQB ...

Enhanced memory allocation for JavaScript clients

Creating a JavaScript script that demands significant amounts of RAM, possibly around 100MB. I need to generate a large array on the client-side. Is there an HTML tag available to allocate more memory for the script? Code: <html> <head> ...

What are the steps to creating a traffic light that operates automatically?

var RED = "#FF0000"; var YELLOW = "#FFFF00"; var GREEN = "#00FF00"; var DARK_RED = "#380000"; var DARK_YELLOW = "#383800"; var DARK_GREEN = "#003800"; var X_ALL = 150; var Y_RED = 100; var Y_Y ...

Implement CSS styling within XML responses in jQuery UI autocomplete

Can you apply a different CSS class to a specific part of the label in the XML response? Currently, the label value is: label: $( "name", this ).text() + ", " + ( $.trim( $( "countryName", this ).text() ) || "(unknown country)" ) + ", " + $( "countryCode" ...

LESS: mastering the dumpLineNumbers function

I'm relatively new to LESS and I have a question regarding the dumpLineNumbers property within the less JavaScript object. Despite adding it to my html file, I am unable to detect any changes in the browser output or debugging tools. Can someone expla ...

Creating a Triangle Slider Component with React and Material-UI (MUI)

Struggling with creating a price control using react js and MUI, similar to the image below: https://i.stack.imgur.com/ZP8oc.png I've searched online for libraries or solutions, but haven't found anything that works. ...