working on it ...

## Filters

Sort by

Found 9,618 snippets matching: center

### Vertically Centered Content

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

```

### 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));
}```

### 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 );
}```

### Center absolute div

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

```

### 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>

```

### 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%);
}```

### 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;
}```

### Centered Layout Fixed Width

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

```

### Centered Layout Fixed Width

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

```

### Vertically Centered Content

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

```
• Public Snippets
• Channels Snippets