grid() code example

Example 1: python grid

example1 = Label(root, text="Top left column")
example1.grid(row=0, column=0)
#Or
example2 = Label(root, text="Middle right colum") .grid(row=1, column=1)

#ColumnSpan
example3 = Label(root, text="Bottom Row")
example3.grid(row=2, columnspan=2)

Example 2: css grid layout

<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
  display: grid;
  grid-template-columns: auto auto auto;
  background-color: #2196F3;
  padding: 10px;
}
.grid-item {
  background-color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.8);
  padding: 20px;
  font-size: 30px;
  text-align: center;
}
</style>
</head>
<body>

  <div class="grid-container">
    <div class="grid-item">1</div>
    <div class="grid-item">2</div>
    <div class="grid-item">3</div>  
    <div class="grid-item">4</div>
    <div class="grid-item">5</div>
    <div class="grid-item">6</div>  
    <div class="grid-item">7</div>
    <div class="grid-item">8</div>
    <div class="grid-item">9</div>  
  </div>

</body>

Tags:

Css Example