📜  html windows logo - PHP (1)

📅  最后修改于: 2023-12-03 15:15:34.649000             🧑  作者: Mango

HTML Windows Logo - PHP

Introduction

In this article, we will discuss how to create a Windows logo using HTML and CSS, and then we will use PHP to add some interactivity to it.

HTML and CSS

First, let's create the HTML structure of our Windows logo. We will use a <div> element with a class name of windows-logo and three nested <div> elements with class names of square.

<div class="windows-logo">
  <div class="square"></div>
  <div class="square"></div>
  <div class="square"></div>
</div>

Next, we will use CSS to style our logo. We will use the transform property to rotate the squares and the background-color property to color them.

.windows-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  width: 200px;
}

.square {
  height: 50px;
  width: 50px;
  background-color: #0078d7;
  transform-origin: center;
}

.square:first-child {
  transform: rotate(0deg);
}

.square:nth-child(2) {
  transform: rotate(90deg);
}

.square:last-child {
  transform: rotate(45deg);
}

Our Windows logo is now complete. It should look like this:

Windows logo

PHP

Now that we have created our logo, let's add some interactivity to it using PHP. We will create a form with a text input and a submit button. When the user types a color into the input and clicks the button, we will use PHP to change the background color of the logo.

<form action="" method="post">
  <input type="text" name="color" placeholder="Enter a color">
  <button type="submit">Change color</button>
</form>

In our PHP code, we will use the $_POST variable to retrieve the color entered by the user. We will then use the style attribute to change the background color of the squares.

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $color = $_POST['color'];
  echo "<style>.square { background-color: $color; }</style>";
}
?>

Our complete PHP code should look like this:

<form action="" method="post">
  <input type="text" name="color" placeholder="Enter a color">
  <button type="submit">Change color</button>
</form>

<div class="windows-logo">
  <div class="square"></div>
  <div class="square"></div>
  <div class="square"></div>
</div>

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $color = $_POST['color'];
  echo "<style>.square { background-color: $color; }</style>";
}
?>

And that's it! We have created a Windows logo using HTML and CSS, and added some interactivity to it using PHP.

Conclusion

In this article, we have learned how to create a Windows logo using HTML and CSS, and then used PHP to add some interactivity to it. We have covered the basics of HTML, CSS, and PHP, and hopefully, you now have a better understanding of how these technologies can be used together to create dynamic web content.