html class declaration code question

Asked 1 years ago, Updated 1 years ago, 433 views

I'm a coding beginner who just started html. I declared a class and declared a class to put an image on the input column, but it does not apply. It only applies to the wrong code What is the problem?

<head>

  <style type="text/css">
    .search {
    position: relative;
    width: 300px; }

  input {
    width: 100%;
    border: 1px solid #bbb;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px; }

  img {
    position : absolute;
    width: 17px;
    top: 10px;
    left: 120px;
    margin: 0; }
  </style>

<img src = "wikipidia-main.jpg" style = "width: 20em; height: 5em;" alt = "위키백과">

<div class="search">
  <input type="text" placeholder="Enter search terms">
  <img src="search_top_en_US.gif">
</div>


</head>

html class

2022-12-20 04:51

1 Answers

Would you like to try this?

/* Apply the following rule to the img element in the element with the .search class */
.search img {
    position : absolute; /* or less omitted */
}

By the way, the head is too big! It's a very deformed child to have an image inside the head and a body inside the input space. Move </head> directly behind </style> and wrap the rest with <body> tags.


2022-12-20 06:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.