По моему опыту, наилучшим способом центрировать ящик горизонтально является применение следующих свойств:
text-align: center;
display: inline-block;
.container {
width: 100%;
height: 120px;
background: #CCC;
text-align: center;
}
.centered-content {
display: inline-block;
background: #FFF;
padding: 20px;
border: 1px solid #000;
}
Center this!
См. также этот Fiddle !
По моему опыту, лучший способ центрировать коробку как вертикально, так и горизонтально - использовать дополнительный контейнер и применять следующие свойства:
display: table;
display: table-cell;
vertical-align: middle;
text-align: center;
display: inline-block;
.outer-container {
display: table;
width: 100%;
height: 120px;
background: #CCC;
}
.inner-container {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.centered-content {
display: inline-block;
background: #FFF;
padding: 20px;
border: 1px solid #000;
}
Center this!
См. также этот скрипт !
using System;
public class Program
{
public static int Compute(int i)
{
i = int.Parse(Console.ReadLine());
for (int n = 0; n <= i; n++)
{
if (n % 2 == 0)
{
Console.WriteLine(n);
}
}
return i;
}
public static void Main()
{
Console.WriteLine("Enter the number: ");
int i=Convert.ToInt32(Console.ReadLine());// Define i
Compute(i);
Console.WriteLine(Compute(i));
}
}