Search
 
SCRIPT & CODE EXAMPLE
 

CSS

css gradient border

  box-sizing: content-box;
  border-width: 8px;
  border-style: solid;
  border-image: linear-gradient(to right bottom, #260B3C, #a053df);
  border-image-slice: 1;
Comment

gradient border with border radius

.rounded-corners-gradient-borders {
  width: 300px;
  height: 80px;
  border: double 4px transparent;
  border-radius: 80px;
  background-image: linear-gradient(white, white), radial-gradient(circle at top left, #f00,#3020ff);
  background-origin: border-box;
  background-clip: content-box, border-box;
}
Comment

rounded gradient border css


div{
  width: 300px;
  height: 80px;
  border: double 5px transparent;
  border-radius: 30px;
  background-image: linear-gradient(white, white),         /*here must be*/
                    linear-gradient(to right, green, gold);    /*both gradients*/
  background-origin: border-box;
  background-clip: content-box, border-box;
}
Comment

linear gradient border

div-border-and-content-background {
  border-top: double 5px transparent;
  
  /* first gradient is for card background, second for border background */
  background-image: linear-gradient(white,white), linear-gradient(to right, grey, black);
  background-clip: padding-box, border-box;
  background-origin: border-box;
  }
Comment

gradient border

.btn-gradient-border {
  color: rgb(var(--text-color));
  border: 2px double transparent;
  background-image: linear-gradient(rgb(13, 14, 33), rgb(13, 14, 33)), radial-gradient(circle at left top, rgb(1, 110, 218), rgb(217, 0, 192));
  background-origin: border-box;
  background-clip: padding-box, border-box;
}
Comment

CSS Border Gradient

@import url('//raw.githubusercontent.com/necolas/normalize.css/master/normalize.css');

html {
    /* just for showing that background doesn't need to be solid */
    background: linear-gradient(to right, #DDD 0%, #FFF 50%, #DDD 100%);
    padding: 10px;
}

.grounded-radiants {
    position: relative;
    border: 4px solid transparent;
    border-radius: 16px;
    background: linear-gradient(orange, violet);
    background-clip: padding-box;
    padding: 10px;
    /* just to show box-shadow still works fine */
    box-shadow: 0 3px 9px black, inset 0 0 9px white;
}

.grounded-radiants::after {
    position: absolute;
    top: -4px; bottom: -4px;
    left: -4px; right: -4px;
    background: linear-gradient(red, blue);
    content: '';
    z-index: -1;
    border-radius: 16px;
}
Comment

Add linear-gradient & border-radius simultaneously to border

			 /* If there is NO content inside the container */
             borderRadius: '10px',
             border:'double 5px transparent',
             backgroundImage: 'linear-gradient(white, white) ,linear-gradient(to left bottom, #5232d2, #006cf4, #0093fb, #00b4f3, #00d0e6, #35d7e4, #50dee2, #66e5e0, #65dce4, #6bd2e5, #74c7e2, #7fbddc)',
             backgroundOrigin: 'border-box',
             backgroundClip: 'content-box, border-box'
             
             /* If there IS content inside the container */
             borderRadius: '10px',
             border:'double 5px transparent',
             backgroundImage: 'linear-gradient(white, white) ,linear-gradient(to left bottom, #5232d2, #006cf4, #0093fb, #00b4f3, #00d0e6, #35d7e4, #50dee2, #66e5e0, #65dce4, #6bd2e5, #74c7e2, #7fbddc)',
             backgroundOrigin: 'border-box',
             backgroundClip: 'padding-box, border-box'
Comment

Container Linear Gradient Border

class UnicornOutlineButton extends StatelessWidget {
  final _GradientPainter _painter;
  final Widget _child;
  final VoidCallback _callback;
  final double _radius;

  UnicornOutlineButton({
    @required double strokeWidth,
    @required double radius,
    @required Gradient gradient,
    @required Widget child,
    @required VoidCallback onPressed,
  })  : this._painter = _GradientPainter(strokeWidth: strokeWidth, radius: radius, gradient: gradient),
        this._child = child,
        this._callback = onPressed,
        this._radius = radius;

  @override
  Widget build(BuildContext context) {
    return CustomPaint(
      painter: _painter,
      child: GestureDetector(
        behavior: HitTestBehavior.translucent,
        onTap: _callback,
        child: InkWell(
          borderRadius: BorderRadius.circular(_radius),
          onTap: _callback,
          child: Container(
            constraints: BoxConstraints(minWidth: 88, minHeight: 48),
            child: Row(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                _child,
              ],
            ),
          ),
        ),
      ),
    );
  }
}

class _GradientPainter extends CustomPainter {
  final Paint _paint = Paint();
  final double radius;
  final double strokeWidth;
  final Gradient gradient;

  _GradientPainter({@required double strokeWidth, @required double radius, @required Gradient gradient})
      : this.strokeWidth = strokeWidth,
        this.radius = radius,
        this.gradient = gradient;

  @override
  void paint(Canvas canvas, Size size) {
    // create outer rectangle equals size
    Rect outerRect = Offset.zero & size;
    var outerRRect = RRect.fromRectAndRadius(outerRect, Radius.circular(radius));

    // create inner rectangle smaller by strokeWidth
    Rect innerRect = Rect.fromLTWH(strokeWidth, strokeWidth, size.width - strokeWidth * 2, size.height - strokeWidth * 2);
    var innerRRect = RRect.fromRectAndRadius(innerRect, Radius.circular(radius - strokeWidth));

    // apply gradient shader
    _paint.shader = gradient.createShader(outerRect);

    // create difference between outer and inner paths and draw it
    Path path1 = Path()..addRRect(outerRRect);
    Path path2 = Path()..addRRect(innerRRect);
    var path = Path.combine(PathOperation.difference, path1, path2);
    canvas.drawPath(path, _paint);
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => oldDelegate != this;
}
Comment

PREVIOUS NEXT
Code Example
Css :: mirror text css 
Css :: responsive media qurries 
Css :: flex center 
Css :: circle css with text in the center 
Css :: css horizontal ul 
Css :: css stop scrollbar 
Css :: add background image and color css 
Css :: css space between td 
Css :: input remove blue glow 
Css :: how to write text on video in html 
Css :: how to link fonts css 
Css :: css media screen 
Css :: css select every 3rd element 
Css :: css limit text length 
Css :: roboto 
Css :: hiding button border when clicked 
Css :: text align left in span 
Css :: make background image full width 
Css :: change font with calc function 
Css :: how to make a div fill the screen 
Css :: padding top ratio 
Css :: css element same line 
Css :: check if audio element is playing css 
Css :: how to make all buttons same size css 
Css :: css hide timeline 
Css :: iPhone XS css 
Css :: apply style to second child div 
Css :: ul list style type image 
Css :: underline css still there after text-decoration: none 
Css :: how to add text stroke in css 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =