working on it ...

Filters

Explore Public Snippets

Sort by

Found 9,618 snippets matching: center

    public by LongBeard modified Feb 10, 2016  143332  2  3  0

    Vertically Centered Content

    Vertically Centered Content: verticallyCenteredContent.css
    .container {
        min-height: 6.5em;
        display: table-cell;
        vertical-align: middle;
    }
    
    

    public by Geometry modified Aug 7, 2016  464  0  5  0

    Center: Computes the center of a given rectangle.

    Computes the center of a given rectangle.
    #region Algebra and geometry tools
    
    /// <summary>
    ///   Computes the center of a given rectangle.
    /// </summary>
    public static Point Center(this Rectangle rectangle)
    {
        return new Point(
            (int)(rectangle.X + rectangle.Width / 2f),
            (int)(rectangle.Y + rectangle.Height / 2f));
    }

    public by Geometry modified Aug 7, 2016  1710  11  5  0

    GetCenterOfGravity: Get center of gravity for the specified list of points.

    Get center of gravity for the specified list of points. List of points to calculate center of gravity for. Returns center of gravity (mean X-Y values) for the specified list of points.
    /// <summary>
    /// Get center of gravity for the specified list of points.
    /// </summary>
    /// 
    /// <param name="cloud">List of points to calculate center of gravity for.</param>
    /// 
    /// <returns>Returns center of gravity (mean X-Y values) for the specified list of points.</returns>
    /// 
    public static Point GetCenterOfGravity( IEnumerable<IntPoint> cloud )
    {
        int numberOfPoints = 0;
        float xSum = 0, ySum = 0;
    
        foreach ( IntPoint pt in cloud )
        {
            xSum += pt.X;
            ySum += pt.Y;
            numberOfPoints++;
        }
    
        xSum /= numberOfPoints;
        ySum /= numberOfPoints;
    
        return new Point( xSum, ySum );
    }

    public by Heddie Franco modified Feb 5, 2015  3403  6  4  1

    Center absolute div

    Center absolute div: centerDiv.css
    #content{
        position:absolute;
        left:0;
        right:0;
        margin-left:auto;
        margin-right:auto;
    }
    
    

    public by cwilli34 modified Feb 21, 2017  950  3  3  0

    Center images with caption aligning beneath the image.

    Center images with caption aligning beneath the image.: center_image.html
    <div style="display: block; text-align: center;">
      <div style="display: inline-block">
        <div class="wrapper" style="display: table; text-align: left">
          <a href="#" target="_blank"><img alt="Wib Ami Video" src="/assets/225577/fullsize/wib_ami_video.jpg" style="display: block; text-align: center;"></a>
          <div class="caption" style="display: table-caption; caption-side: bottom;">Ami: Network means an open, helping hand</div>
        </div>
      </div>
    </div>
    
    

    public by samuelcrockford modified Mar 14, 2019  58  1  3  0

    Centre child inside its parent - Old School Way

    How to centre a div vertically and horizontally inside its parent
    /* Center a div - The old school way*/
    .parent { /* Center my child relative to me */
      position: relative;
    }
    .child { /* Center me inside my parent*/
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    public by Geometry modified Aug 17, 2016  851  0  5  0

    Centering: Creates a centering matrix of size <c>N x N</c> in the form <c>(I - 1N)</c> where <c>1N</c> is a matrix with all elements equal to <c>1 / N</c>.

    Creates a centering matrix of size N x N in the form (I - 1N) where 1N is a matrix with all elements equal to 1 / N.
    /// <summary>
    ///   Creates a centering matrix of size <c>N x N</c> in the
    ///   form <c>(I - 1N)</c> where <c>1N</c> is a matrix with 
    ///   all elements equal to <c>1 / N</c>.
    /// </summary>
    /// 
    public static double[,] Centering(int size)
    {
        if (size < 0)
        {
            throw new ArgumentOutOfRangeException("size", size,
                "The size of the centering matrix must be a positive integer.");
        }
    
        double[,] C = Matrix.Square(size, -1.0 / size);
    
        for (int i = 0; i < size; i++)
            C[i, i] = 1.0 - 1.0 / size;
    
        return C;
    }

    public by Fresh-Dev modified Feb 10, 2016  2694  0  3  0

    Centered Layout Fixed Width

    Centered Layout Fixed Width: centeredLayoutFixedWidth.css
    #page-wrap {
        width: 800px;
        margin: 0 auto;
    }
    
    

    public by LongBeard modified Feb 10, 2016  2149  1  4  0

    Centered Layout Fixed Width

    Centered Layout Fixed Width: centeredLayoutFixedWidth.css
    #page-wrap {
        width: 800px;
        margin: 0 auto;
    }
    
    

    public by Fresh-Dev modified Feb 10, 2016  1475  1  3  0

    Vertically Centered Content

    Vertically Centered Content: verticallyCenteredContent.css
    .container {
        min-height: 6.5em;
        display: table-cell;
        vertical-align: middle;
    }
    
    
    • Public Snippets
    • Channels Snippets