CSS карт при наведении на зигзаг, а также текст выходит за рамки (переполнение) - PullRequest
0 голосов
/ 28 апреля 2020

У меня есть страница, состоящая из css карточек, все работает нормально, но единственная проблема - это текст, который мне нужно отобразить на css карточках. , и еще одна вещь, которая должна быть исправлена, это эффект наведения, когда я наведите курсор на элемент, оставшиеся css карты расположены зигзагообразно. проверьте следующий код.

<!DOCTYPE html>
<html>
<head>
  <title>Easy</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
    .self{
      margin-left:160px;
    }
* {
  box-sizing: border-box;
}

body {
  font-family: Arial, Helvetica, sans-serif;
}

/* Float four columns side by side */
.column {
  float: left;
  width: 25%;
  padding: 0 10px;
  margin-bottom: 20px;
  flex-basis: 25%;
}

/* Remove extra left and right margins, due to padding */
.row {margin: 0 -5px;}

/* Clear floats after the columns */
.row:after {

  content: "";
  display: table;
  clear: both;
}

 Responsive columns 
@media screen and (max-width: 600px) {
  .column {
    width: 100%;
    display: block;
    margin-bottom: 20px;
  }
}

/* Style the counter cards */
.card {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 1);
  padding: 16px;
  text-align: center;
  background-color: #f1f1f1;
  transition: width 2s,height 4s;
  transition-timing-function: ease-in-out;
}
    .card:hover{
      background-color: lightgreen;
      transition-timing-function: ease-in-out;
      width: 300px;
      height: 300px;
    }
</style>
</head>
<body style="background-color: #dae2e3;">
    <div class="self">
  <div class="column w3-button">
    <div class="card">
      <h1><?php echo"$value"; ?></h1>
      <h3 style="overflow-x:page-break-inside:inherit;"><?php echo"$description";?></h3>
      <h3><?php echo"$index";?></h3>
    </div>
  </div>
</div>

  <?php }?>

1 Ответ

0 голосов
/ 28 апреля 2020

Эта проблема возникает из-за того, что вы указали фиксированную высоту карты при наведении курсора.

Удалите height: 300px;, и ваша проблема при наведении исчезнет.

.self {
  margin-left: 160px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: Arial, Helvetica, sans-serif;
}


/* Float four columns side by side */

.column {
  float: left;
  width: 25%;
  padding: 0 10px;
  margin-bottom: 20px;
  flex-basis: 25%;
}


/* Remove extra left and right margins, due to padding */

.row {
  margin: 0 -5px;
}


/* Clear floats after the columns */

.row:after {
  content: "";
  display: table;
  clear: both;
}

@media screen and (max-width: 600px) {
  .column {
    width: 100%;
    display: block;
    margin-bottom: 20px;
  }
}


/* Style the counter cards */

.card {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 1);
  padding: 16px;
  text-align: center;
  background-color: #f1f1f1;
  transition: width 2s, height 4s;
  transition-timing-function: ease-in-out;
}

.card:hover {
  background-color: lightgreen;
  transition-timing-function: ease-in-out;
  width: 300px;
  /*height: 300px;*/
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

<body style="background-color: #dae2e3;">
  <div class="self">
    <div class="column w3-button">
      <div class="card">
        <h1>my card have an overflow problem</h1>
        <h3 style="overflow-x: page-break-inside:inherit;">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque quisquam voluptate velit perferendis. Vel, cum dignissimos consequatur recusandae quisquam, quibusdam! Amet possimus sunt veritatis quos, nostrum minima deleniti, voluptatem repellat.</h3>
        <h3>1</h3>
      </div>
    </div>
  </div>
</body>
...