logo
down
shadow

CSS - Creating rounded rectangle


CSS - Creating rounded rectangle

By : user2952037
Date : November 18 2020, 03:49 PM
this will help Is there a way to create a rounded button as shown in the picture using CSS (without using Canvas or SVG)? , This is possible using :after and :before :pseudo-elements.
code :
div {
  position: relative;
  margin: 30px;
  width: 150px;
  height: 100px;
  background: #FF5656;
  border-radius: 1000px / 200px;
}
div:after, div:before {
  position: absolute;
  content: '';
  width: 10px;
  height: 72%;
  border-top-left-radius: 200px 1000px;
  border-bottom-left-radius: 200px 1000px;
  left: -6px;
  top: 14%;
  background: #FF5656;
}
div:after {
  border-radius: 0;
  border-top-right-radius: 200px 1000px;
  border-bottom-right-radius: 200px 1000px;
  left: calc(100% - 4px);
}
<div></div>
input {
  width: 150px;
  height: 100px;
  background: #FF5656;
  border-radius: 1000px / 200px;
  border: 0;
  cursor: pointer;
  color: black;
  font-size: 16px;
}
input::-moz-focus-inner {
  border: 0;
}
input:focus {
  outline: none;
}
.btn-container {
  position: relative;
  width: 150px;
  height: 100px;
  margin: 30px;
}
.btn-container:after,
.btn-container:before {
  position: absolute;
  content: '';
  width: 10px;
  height: 72%;
  border-top-left-radius: 200px 1000px;
  border-bottom-left-radius: 200px 1000px;
  left: -6px;
  top: 14%;
  background: #FF5656;
}
.btn-container:after {
  border-radius: 0;
  border-top-right-radius: 200px 1000px;
  border-bottom-right-radius: 200px 1000px;
  left: calc(100% - 4px);
}
<div class="btn-container">
  <input type="button" value="Button" />
</div>
button {
  position: relative;
  width: 150px;
  height: 100px;
  background: #FF5656;
  border-radius: 1000px / 200px;
  border: 0;
  cursor: pointer;
  color: black;
  font-size: 16px;
}
button::-moz-focus-inner {
  border: 0;
}
button:focus {
  outline: none;
}
button:after,
button:before {
  position: absolute;
  content: '';
  width: 10px;
  height: 72%;
  border-top-left-radius: 200px 1000px;
  border-bottom-left-radius: 200px 1000px;
  left: -6px;
  top: 14%;
  background: #FF5656;
}
button:after {
  border-radius: 0;
  border-top-right-radius: 200px 1000px;
  border-bottom-right-radius: 200px 1000px;
  left: calc(100% - 4px);
}
<button>Button</button>


Share : facebook icon twitter icon
Creating a rectangle shape with only two rounded edges

Creating a rectangle shape with only two rounded edges


By : First Last
Date : March 29 2020, 07:55 AM
it should still fix some issue I changed the android:radius attribute to android:topRightRadius and android:topLeftRadius
Android - Rounded Rectangle within Rounded Rectangle

Android - Rounded Rectangle within Rounded Rectangle


By : oussama
Date : March 29 2020, 07:55 AM
With these it helps I am currently designing a login page and I've run into a problem with using rounded rectangles. My current layout looks somewhat like this: , On the EditText you may want to try layout_marginRight in the XML.
Creating a progress indicator with a rounded rectangle

Creating a progress indicator with a rounded rectangle


By : Mohammed Diallo
Date : March 29 2020, 07:55 AM
around this issue I found a solution so the loading indicator works for round corners:
code :
let queueShapeLayer = CAShapeLayer()

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    // Queue timer
    let radius = addToQueue.layer.cornerRadius
    let diameter = radius * 2
    let totalLength = (addToQueue.frame.width - diameter) * 2 + (CGFloat.pi * diameter)

    let queuePath = UIBezierPath(roundedRect: addToQueue.frame, cornerRadius: radius)
    queueShapeLayer.path = queuePath.cgPath
    queueShapeLayer.lineWidth = 5
    queueShapeLayer.strokeColor = UIColor.white.cgColor
    queueShapeLayer.fillColor = UIColor.clear.cgColor
    queueShapeLayer.strokeStart = 0.25 - CGFloat.pi * diameter / 3 / totalLength // Change the '0.25' to 0.5, 0.75 etc. wherever you want the bar to start
    queueShapeLayer.strokeEnd = queueShapeLayer.strokeStart + 0.5 // Change this to the value you want it to go to (in this case 0.5 or 50% loaded)
    view.layer.addSublayer(queueShapeLayer)
}
How can I draw a rounded rectangle as the border for a rounded Form?

How can I draw a rounded rectangle as the border for a rounded Form?


By : zzimbler
Date : March 29 2020, 07:55 AM
This might help you A base implementation of what is described in the comments.
The Form frmRoundCorners provides some properties that allow to draw its rounded area with a custom BackColor, a custom BorderColor and a custom inner border color, acting as a shadow for the internal side of the Form's border.
code :
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

[ToolboxItem(false)]
public partial class frmRoundCorners : baseForm
{
    private GraphicsPath pathRegion = new GraphicsPath(FillMode.Winding);
    private GraphicsPath pathBorder;
    Point pMousePosition = Point.Empty;

    public frmRoundCorners()
    {
        SetStyle(ControlStyles.AllPaintingInWmPaint |
                 ControlStyles.UserPaint |
                 ControlStyles.OptimizedDoubleBuffer |
                 ControlStyles.ResizeRedraw, true);
        InitializeComponent();
    }

    protected override void OnMouseDown(MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left) {
            pMousePosition = e.Location;
        }
        base.OnMouseDown(e);
    }

    protected override void OnMouseMove(MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left) {
            Point screenPos = PointToScreen(e.Location);
            this.Location = new Point(screenPos.X - pMousePosition.X, screenPos.Y - pMousePosition.Y);
        }
        base.OnMouseMove(e);
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);

        e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
        e.Graphics.PixelOffsetMode = PixelOffsetMode.Half;
        RoundedCornerRectangle(this.ClientRectangle);
        RectangleF rect = pathRegion.GetBounds();
        float scaleX = 1 - (BorderSize / rect.Width);
        float scaleY = 1 - (BorderSize / rect.Height);
        using (Pen pen = new Pen(BorderColor, BorderSize))
        using (Pen penBorder = new Pen(InternalBorderColor, 2))
        using (Brush brush = new SolidBrush(FillColor))
        using (Matrix mx = new Matrix(scaleX, 0, 0, scaleY, (pen.Width / 2), (pen.Width / 2)))
        {
            e.Graphics.Transform = mx;
            e.Graphics.FillPath(brush, pathRegion);
            e.Graphics.DrawPath(penBorder, pathBorder);
            e.Graphics.DrawPath(pen, pathRegion);
        }
    }

    private void RoundedCornerRectangle(Rectangle r)
    {
        pathRegion = new GraphicsPath(FillMode.Alternate);
        float innerCurve = this.CurveAngle - this.m_PenSizeOffset;

        pathRegion.StartFigure();
        pathRegion.AddArc(r.X, r.Y, CurveAngle, CurveAngle, 180, 90);
        pathRegion.AddArc(r.Right - CurveAngle, r.Y, CurveAngle, CurveAngle, 270, 90);
        pathRegion.AddArc(r.Right - CurveAngle, r.Bottom - CurveAngle, CurveAngle, CurveAngle, 0, 90);
        pathRegion.AddArc(r.X, r.Bottom - CurveAngle, CurveAngle, CurveAngle, 90, 90);
        pathRegion.CloseFigure();

        pathBorder = new GraphicsPath();
        pathBorder.StartFigure();
        pathBorder.AddArc(r.X + m_PenSizeOffset, r.Y + m_PenSizeOffset, innerCurve, innerCurve, 180, 90);
        pathBorder.AddArc(r.Right - innerCurve - m_PenSizeOffset, r.Y + m_PenSizeOffset, innerCurve, innerCurve, 270, 90);
        pathBorder.AddArc(r.Right - innerCurve - m_PenSizeOffset, r.Bottom - innerCurve- m_PenSizeOffset, innerCurve, innerCurve, 0, 90);
        pathBorder.AddArc(r.X + m_PenSizeOffset, r.Bottom - innerCurve - m_PenSizeOffset, innerCurve, innerCurve, 90, 90);
        pathBorder.CloseFigure();
    }
}

public class baseForm : Form
{
    private Color m_InternalBorderColor = Color.FromArgb(128, 128, 128);
    private Color m_BorderColor = Color.Red;
    private Color m_FillColor = Color.WhiteSmoke;
    private float m_PenSize = 6f;
    private float m_CurveAngle = 60.0f;
    internal float m_PenSizeOffset = 3f;

    public baseForm() => InitializeComponent();
    private void InitializeComponent() => FormBorderStyle = FormBorderStyle.None;

    [EditorBrowsable(EditorBrowsableState.Always), Browsable(true), Category("Appearance")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    [DefaultValue(60.0f)]
    public virtual float CurveAngle
    {
        get => this.m_CurveAngle;
        set {
            this.m_CurveAngle = Math.Max(Math.Min(value, 180), 15);
            Invalidate();
        }
    }
    [EditorBrowsable(EditorBrowsableState.Always), Browsable(true), Category("Appearance")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    [DefaultValue(6.0f)]
    public virtual float BorderSize
    {
        get => this.m_PenSize;
        set {
            this.m_PenSize = value;
            this.m_PenSizeOffset = value / 2.0f;
            this.Invalidate();
        }
    }

    [EditorBrowsable(EditorBrowsableState.Always), Browsable(true), Category("Appearance")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public virtual Color BorderColor
    {
        get => this.m_BorderColor;
        set {
            this.m_BorderColor = value;
            this.Invalidate();
        }
    }

    [EditorBrowsable(EditorBrowsableState.Always), Browsable(true), Category("Appearance")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public virtual Color FillColor
    {
        get => this.m_FillColor;
        set {
            this.m_FillColor = value;
            this.Invalidate();
        }
    }

    [EditorBrowsable(EditorBrowsableState.Always), Browsable(true), Category("Appearance")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    [Description("Get or Set the Color of the internal border")]
    public virtual Color InternalBorderColor
    {
        get => this.m_InternalBorderColor;
        set {
            this.m_InternalBorderColor = value;
            this.Invalidate();
        }
    }

    [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    [DefaultValue(FormBorderStyle.None)]
    public new FormBorderStyle FormBorderStyle
    {
        get => base.FormBorderStyle;
        set => base.FormBorderStyle = FormBorderStyle.None;
    }
}
How to draw a rounded rectangle (rectangle with rounded corners) with OpenCV?

How to draw a rounded rectangle (rectangle with rounded corners) with OpenCV?


By : user4677644
Date : March 29 2020, 07:55 AM
it fixes the issue I realized, this is much easier that I thought. Here is my function. I hope it is helpful for someone.
Related Posts Related Posts :
  • Webpage doesn't scroll smoothly on screen
  • YouTube iframe, browser looks for file locally
  • html displaying inline image
  • Font acting differently on IE and Firefox
  • Encoding and decoding of the character references
  • An Image Button navigate to another site html/css
  • IE8 "Save Target as ..." won't display for block elements
  • Image hover transition for span - CSS
  • How to apply min and max on textarea?
  • How to draw multiple horizontal lines (Notebook Paper effect) using css?
  • Table Printing Issue: Gaps in top and Bottom Border of th Elements
  • grouping elements with div and applying stylesheet for that group
  • Click <div> to expand, then click again to shrink - Its expanding, just not shrinking
  • CSS - How can I center a <script>'s output?
  • Django's template variable gets interpreted as HTML
  • ngx datatable vertical scroll with rowheight set to auto
  • How to make input text border with CSS when it's OnFocus
  • Anyone know of a calendar web widget for my website I could use?
  • How does Bootstrap manage to use fixed positioning for navbar on iOS?
  • Centered text in fully clickable table cell
  • Compare HTML and HTML5
  • steps of creating webpage in bangla
  • css root element margin
  • What is the point of using absolute positioning in CSS?
  • Responsive solution for long URLs (that exceed the device width)
  • Divs don't collapse as they should - media queries
  • QTreeWidgetItem display html
  • Testing html/css image on local from jfiddle
  • long attribute value of HTML
  • Why my svg picture is truncated at the bottom when embedded in html
  • Display CSS: some divs fixed, some flexible (2)
  • How to append href strings with variables in html with PHP?
  • css - Why is there a big white space between text lines?
  • div image position fixed + scroll
  • Hide specific elements from html using css
  • how to align the arrow in menu item?
  • How do I create a trapezoidal button using CSS?
  • Background position seems to be inaccurate
  • CSS background color is overruled by the background image
  • Oblique or twisted border shape
  • Overflow in div tag doesn't work
  • How to show the vertical image into horizontal manner using HTML and CSS?
  • css3 animation issue move div to left and move it back
  • HTML <code> - get rid of newlines
  • Vertical Align Two Spans (Different font size)
  • Position fixed not working with video poster
  • Having issues placing html buttons side by side in a form
  • how to center text in the middle of the page
  • Sublime Autocompletion for HTML using Emmet inside .sublime-autocompletion file
  • Align bottom wrapped text at the left of an image
  • I'm trying to get :after:hover to work
  • Header and Picture won't Display Correctly
  • SVG stacking, anchor elements, and HTTP fetching
  • Positioning two elements on opposite ends of a 100% with header
  • How to overlay an image inside an image with HTML, CSS
  • Selected date isn't kept in select box
  • How to change background colour of entire div on hover?
  • Two gradients with two distinct sections with just one div element
  • Indent even rows of hexagons in CSS
  • Unwanted filled letters in webpage
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org