Border with curved edges

Having an issue with content boundaries while using CSS rounded corners in Firefox. Here is the code snippet:

Code

<html>
<head>
   <style>
      #outter {
            width: 200px;
            margin: auto;
            text-align: center;
            border: 1px solid #333;
            -moz-border-radius: 15px;
        }
        #inner {
            background: red;
            opacity: 0.5;
        }
    </style>
</head>
<body>
<div id="outter">
    <div id="inner">text</div>
</div>
</body>
</html>

Effect

alt text http://img256.imageshack.us/img256/2108/testew.png

To avoid this problem, one solution is to define -moz-border-radius for each child of outter. Are there any other alternative methods that I might be overlooking?

Edit

A more complex scenario where multiple inner divs have different background-color properties:

<div id="outter">
    <div id="inner1" style="background: blue">text</div>
    <div id="inner2" style="background: gray">text</div>
    ...
    <div id="innerN" style="background: yellow">text</div>
</div>

Answer №1

If you want to achieve a similar effect, try the following code:

  #outter {
        width: 200px;
        margin: auto;
        text-align: center;
        border: 1px solid #333;
        -moz-border-radius: 15px;
        background: red;
    }
    #inner {
        opacity: 0.5;
    }

To ensure proper rendering, move the background styling to the outer parent element. You can view an example here. For compatibility with other WebKit-based browsers, add the following lines of code:

-moz-border-radius: 15px; 
-webkit-border-radius: 15px;

Update for edit: In Firefox, adjust the inner div by subtracting a pixel to account for the border. Modify the CSS as shown below:

#outter {
    width: 200px;
    margin: auto;
    text-align: center;
    border: 1px solid #333;
    -moz-border-radius: 15px;
    -webkit-border-radius: 15px;
    background: red;
}
#outter > div:first-child {
    -moz-border-radius-topleft: 14px;
    -moz-border-radius-topright: 14px;
     -webkit-border-top-left-radius: 14px;
     -webkit-border-top-right-radius: 14px;
}
#outter > div:last-child {
    -moz-border-radius-bottomleft: 14px;
    -moz-border-radius-bottomright: 14px;
     -webkit-border-bottom-left-radius: 14px;
     -webkit-border-bottom-right-radius: 14px;
}
#inner {
    opacity: 0.5;
}
​

Please note that due to variations in rendering across different browsers, the rounded corners on the inner divs may not be perfect in WebKit. Adjust these values to suit your preferences.

Answer №2

In case you're looking to achieve rounded corners in Internet Explorer without using images, be sure to explore DDRoundies.

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

Issue with Responsive Behavior of Multi-Row Cards in Bootstrap 4

My goal is to create responsive rows of cards with some margin, but I am running into issues. When I use margin:5px; on my cards, the row overflows and they are not centered correctly. There seems to be extra space on the right side of the cards. How can I ...

Utilizing JavaScript for manipulating arrays and displaying images

After asking this question previously without a satisfactory solution, I am hoping to provide better clarification. Imagine having an array with 3 items and it lands on 0 - a code is set up to display this in a div. Now, I want the image to be shown righ ...

Executing the main process function

One of the challenges I'm facing is calling a function from the main process in Javascript while a button is clicked in another file. Here is the code snippet: Main.js const electron = require( 'electron') const {app, BrowserWindow} = elec ...

Easy PHP navigation options

Creating a basic PHP page with includes is proving challenging when it comes to navigating URLs using '../' to find the correct path to the folder. Is there a straightforward way to set up a simple PHP navigation without involving MySQL or other ...

Strange behavior of focus()

My objective is to launch a popup containing an input field and automatically bring focus to that input. I have attempted using $('#input').focus(), $('#input').first().focus(), and $('#input')[0].focus(), but unfortunately, ...

Adjusting the width of an image in Safari

I just launched my website, but I encountered an issue with the image size in Safari. In my CSS, I set the width like this: img { width: 450%; } Here is the site: I can't figure out why the images display correctly in Chrome and Mozilla, but ...

Tips for sending parameters to a web service URL through a Phonegap HTML page

In my Phone Gap application, I have an HTML page where I need to pass the values like name, contact, etc. to a Webservice URL. However, I am unsure of where to write the code and how to call the webservice URL. Here is a snippet of my HTML code: <div ...

Google Map with rounded corners that have a transparent design

Trying to create a circular Google map using CSS3 border-radius, but having issues with browsers other than Firefox. Here's the code snippet: <div class="map mapCircle" style="position: relative; background-color: transparent; overflow: hidden;"&g ...

Is it possible to display two menus on opposite sides of the screen while using Google Maps?

Currently, I am working on developing a Progressive Web App using Vue.js and Vuetify.js. My goal is to have two buttons overlaid on Google Maps - one on the left side of the screen to open a navigation drawer, and another on the right side to display user ...

What is causing the TouchSwipe jQuery plugin not to function in my code?

I have integrated the TouchSwipe jQuery plugin into my code to detect mouse movement and display the number of pixels moved when swiping left or right. To download the TouchSwipe jQuery plugin, I visited this link: TouchSwipe and then proceeded to use it ...

Style the labels on the axis of Frappe Charts with colors (potentially utilizing the appropriate CSS selector)

Is it possible to style the x and y axis labels in a Frappe chart with different colors? https://i.stack.imgur.com/A3vUq.png While trying to identify the CSS selectors using Chrome DevTools, I found that a single text element (representing an x axis labe ...

What is the best way to resize an image within an SVG shape to completely fill the boundaries?

There is an SVG shape in the form of a parallelogram that has been filled with an image. To view the demo, click here. The code for the SVG object is as follows: <svg style="overflow:visible; margin-left:111px; margin-top:22px; " height="86" width=" ...

Is it possible to include both the value and text of a dropdown in form.serialize?

For my project, I need to serialize the form data. However, when it comes to dropdowns, only the values are captured and not the text of the selected option. <select name='attend'> <option value="1" selected="selected">Question&l ...

Out of reach: Menu div slides up on click outside

<a class="btn">Click ME </a> <div class="content"> Content </div> $('.btn').click(function(){ $('.content').slideToggle(); }); Check out the example here Everything is working properly, but I have a q ...

Tips for extracting header ID from the HTML/DOM using react and typescript

I developed a unique app that utilizes marked.js to convert markdown files into HTML and then showcases the converted content on a webpage. In the following code snippet, I go through text nodes to extract all raw text values that are displayed and store t ...

Discovering the method for retrieving JavaScript output in Selenium

Whenever I need to run JavaScript code, the following script has been proven to work effectively: from selenium import webdriver driver=webdriver.Firefox() driver.get("https:example.com") driver.execute_script('isLogin()') However, when I atte ...

Adding and removing form fields in a table dynamically using AngularJS

I need to dynamically add multiple form fields when a button is pressed, and I want all the fields to be displayed in a table format (each field should have its own space in a <td>field</td> structure). Currently, I am facing an issue where if ...

Creating a function to target a specific HTML class in Angular can be achieved by utilizing Angular

Can a function be created for the entire class instead of adding it to each individual line? In this case, I have a class called "dropdown-item" for each link with this class, and I want them all to have the same function. <li class="nav-item dr ...

Having difficulty with category level activation while implementing PHP page navigation with arrays and foreach loop

After receiving some excellent assistance from CBroe and @MeathCoder in a previous post, I managed to make some amazing changes. However, I'm currently facing an issue with setting the category as active. Here's the code snippet I'm working ...

Parent whose height is less than that of the child element

I'm working on creating a side menu similar to the one on this website. However, I'm facing an issue with the height of the #parent list element. I want it to match the exact same height as its content (the #child span - check out this jsfiddle). ...