How To Use Css Margin Styles

Tanggal : 14 Feb 2023, Category : CSS, Create By : admin

In CSS, the margin property is used to add space around an HTML element. There are different ways to use the margin property in CSS, depending on the desired effect.

Here are some examples:

  1. Set the margin for all sides of an element:
    margin: 10px;

    This will add 10 pixels of margin to all sides of the element.

  2. Set the margin for individual sides of an element:
    margin-top: 10px;
    margin-right: 20px;
    margin-bottom: 30px;
    margin-left: 40px;

    This will add 10 pixels of margin to the top, 20 pixels to the right, 30 pixels to the bottom, and 40 pixels to the left of the element.

  3. Set the margin for opposite sides of an element:
    margin: 10px 20px;

    This will add 10 pixels of margin to the top and bottom, and 20 pixels of margin to the left and right of the element. 

  4. Set the margin to auto to horizontally center an element:
    margin: 0 auto;

    This will center the element horizontally within its parent container.

  5. Use negative margin to overlap elements:
    margin: -10px;

    This will overlap the element with its neighboring elements by 10 pixels.

You can also use shorthand margin properties to specify multiple values at once. For example:

margin: 10px 20px 30px 40px;
 

This is equivalent to setting margin-top to 10px, margin-right to 20px, margin-bottom to 30px, and margin-left to 40px.


Keyword:
  • How To Use Css Margin Styles

Artikel Lain

Pengertian Dan Fungsi Css Dalam Pembuatan Website

Date : 15 Aug 2018, Category : Pemprograman Website, Create By : admin

CSS adalah singkatan dari Cascading Style Sheet atau di terjemahkan di google translate menjadi Lembar bergaya susun. Yaitu sebuah perintah atau intruksi yang dapat digunakan untuk menampilkan text dengan design yang menarik untuk sebuah .....

Membuat Background Gradient Css

Date : 11 Sep 2018, Category : CSS, Create By : admin

Hay Brow, selamat datang kembali di wesbite gudang ilmu aplikasi, tempatnya anda menambah ilmu. Kali ini kami akan membahasa mengenai membuat background gradient dengan css. Background atau bisa disebut latar belakang .....

Mengenal Dan Membuat Enkripsi Php

Date : 02 Jan 2019, Category : Tutorial, Create By : admin

Enkripsi adalah sebuah proses mengamankan sebuah informasi dengan membuat informasi itu tidak bisa di baca secara manual agar informasi tersebut tidak bisa di ketahui oleh orang lain, bisanya enkripsi sering .....