Как мне изменить свой код, чтобы сделать его более отзывчивым? - PullRequest
0 голосов
/ 11 апреля 2019

Я сейчас создаю свой первый сайт.У меня есть кнопка в середине и немного текста выше.Я не получаю отзывчивый дизайн 100% правильно.Я добавил несколько медиа-запросов, чтобы адаптировать дизайн к разным размерам браузера.Самая большая проблема в том, что когда я увеличиваю масштаб, весь макет портится.Может быть, вы можете быстро взглянуть на мой код и дать мне несколько советов.


body,
html {
  min-height: 100%;
}

body {
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.6em;
  margin: 0;
  height: 100%;
  overflow: hidden;
}

.bild {
  background-repeat: no-repeat;
  background-size: cover;
}

#caption {
  font-size: 14px;
  margin-left: 3%;
  font-family: 'Quicksand', sans-serif;
}

#main-footer {
  width: 100%;
  height: 40px;
  background-color: #0005;
  position: fixed;
  left: 0;
  bottom: 0;
  line-height: 10px;
  padding-left: 3%;
}

#main-footer p {
  font-family: 'Quicksand', sans-serif;
  float: left;
}

#main-footer a {
  font-family: 'Quicksand', sans-serif;
  float: right;
  color: #fff;
  padding-right: 5%;
  text-decoration: none;
  margin-top: 16px;
}

#spruchErstellen {
  font-family: 'Architects Daughter', cursive;
  text-align: center;
  margin-top: 25%;
  font-size: 45px;
  margin-left: 25%;
  margin-right: 25%;
}

.container {
  width: 80%;
  margin: auto;
  overflow: hidden;
  position: relative;
}

.block {
  width: 100%;
  font-size: 30px;
  position: relative;
}

.button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50% -50%);
  margin-top: -40px;
  margin-left: -120px;
  font-family: 'Architects Daughter', cursive;
}

.button {
  background: none;
  color: #ccc;
  width: 240px;
  height: 80px;
  border: 2px solid #fff;
  font-size: 24px;
  border-radius: 4px;
  transition: .6s;
  overflow: hidden;
  font-style: bold;
  color: #fff;
}

button:focus {
  outline: none;
}

button:before {
  content: '';
  display: block;
  position: absolute;
  background: rgba(255, 255, 255, .5);
  width: 60px;
  height: 100%;
  left: 0;
  top: 0;
  opacity: .5s;
  filter: blur(30);
  transform: translateX(-130px) skewX(-15deg);
}

button:after {
  content: '';
  display: block;
  position: absolute;
  background: rgba(255, 255, 255, .2);
  width: 30px;
  height: 100%;
  left: 30px;
  top: 0;
  opacity: 0;
  filter: blur (30px);
  transform: translate(-100px) scaleX(-15deg);
}

button:hover {
  background: #cc0000;
  cursor: pointer;
}

button:hover:before {
  transform: translateX(300px) skewX(-15deg);
  opacity: .6;
  transition: .7s;
}

button:hover:after {
  transform: translateX(300px) skewX(-15deg);
  opacity: 1;
  transition: .7s;
}

@media only screen and (min-width:1101px) {
  #spruchErstellen {
    font-family: 'Architects Daughter', cursive;
    text-align: center;
    margin-top: 7%;
    font-size: 45px;
    margin-left: 25%;
    margin-right: 25%;
    line-height: 50px;
  }
  .button {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50% -50%);
    margin-top: -40px;
    margin-left: -120px;
  }
}

У меня есть медиа-запросы, но я не вставил все, чтобы сделать код более понятным.Как я уже упоминал, я хотел бы сделать его более отзывчивым.

1 Ответ

0 голосов
/ 11 апреля 2019

Старайтесь избегать использования px. Попробуй использовать %.

Кроме того, вы можете использовать CSS-фреймворк, такой как Bootstrap, чтобы сделать это для вас: https://getbootstrap.com/

...