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

css border top linear gradient

.bordertest {
    height:300px;
    width:300px;
    border-top:30px solid #c4268c;
    background:#000;
    position:relative;
    margin:1em;
}
.bordertest:first-child:before {
    content:'';
    position:absolute;
    width:100%;
    height:30px;
    background:linear-gradient(to left, #c4268c, #9a0b72);
    top:-30px;
    left:0;
}
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 :: can span have width 
Css :: how to install tailwind css in html 
Css :: html table scrollable body fixed header 
Css :: css textarea set max characters 
Css :: center div css flex 
Css :: [deprecation] Running tailwindcss without -i, please provide an input file. 
Css :: css square image 
Css :: scrollbar css 
Css :: css keyframes 
Css :: &:disabled not working sass 
Css :: css inverted border radius 
Css :: css center div 
Css :: over to remove padding css 
Css :: changing bakcgound color like animation using tailwind 
Css :: free computer screen recording software 
Css :: css remove highlight on input text 
Css :: CSS technique for a horizontal line with icons in the middle 
Css :: setting multiple styles in javascript 
Css :: css circle shadow 
Css :: padding css 
Css :: responsive width css 
Css :: css disabled button hover style 
Css :: javafx button padding css 
Css :: define element opacity css 
Css :: scss maps´ 
Css :: how to dedeclare a variable and use it in css 
Css :: call css html 
Css :: media breakpoints 
Css :: ease in out css 
Css :: text shadow css 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =