Поделиться кнопками, покрывающими текст, когда я изменяю размер страницы - PullRequest
0 голосов
/ 20 октября 2019

У меня проблема с моей страницей. Я добавил кнопки «Поделиться» в свое сообщение, но когда я изменил размер страницы, кнопка переместилась на весь текст. Как я могу сделать страницу отзывчивой?

Теперь я делаю кнопку фиксированной, чтобы они оставались справа от страницы, потому что, если я поставлю относительную, они останутся после основного контента в центре

Этонаходится в обычном режиме: Обычный стиль просмотра

Это когда я изменяю размер страницы: проблема

Вот мой код CSS

кнопка css

/*
* share button
*/

@import url("//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css");


/*Loghi dentro al rettangolo*/
.social-links{
  position: fixed;
  font-size: 14px;
  text-align: center;
  right: 20px;
  top: 40%;


}
.social-links a{
    width: 25px;
    height: 25px;
    line-height: 25px !important;
    position: relative;
    margin: 15px 5px;
    text-align: center;
    display: list-item;
    list-style: none;
    color: #111;

    -webkit-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);  
    -moz-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
    -o-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);
    -ms-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
    transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);
}
.social-links a i,
.social-links a span{
    position: relative;
    top: 2px;
    left: 1px; 
}
.social-links a:before{
    content: "";
    display: list-item;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border: 1px solid #111;

    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    border-radius: 2px;

    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);

    -webkit-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);  
    -moz-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
    -o-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);
    -ms-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
    transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);

}
.social-links a:hover{
    color: #fff;
}
.social-links a:hover:before{
    background: #111;
}

страница css

body {
    font-family: 'LatoLatinWeb', Avenir, HelveticaNeue-Light, "Helvetica Neue Light",
                 "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
    color: #141823;
    font-size: 1.1em;
    background-color: #ecedef;
    margin: 0;
    padding: 0 0 2em 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    word-break: break-word;
}
.content {
    background-color: white;
    padding: 2em 0;
    margin-bottom: 2em;
    width: 100%;
    max-width: 52rem;
    border-radius: 0.3rem;
    transition: transform 0.2s cubic-bezier(0.25,0.8,0.25,1), box-shadow 0.2s cubic-bezier(0.25,0.8,0.25,1);
    box-shadow: 0 0.7rem 1.4rem 0 rgba(0,0,0,0.25), 0 0.5rem 0.5rem 0 rgba(0,0,0,0.22);
}

Спасибо, если вы можете мне помочь

1 Ответ

1 голос
/ 20 октября 2019

Метод 1:
с использованием vw и vh или (vmax и vmin):

@import url("//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css");


/*Loghi dentro al rettangolo*/
.social-links{
  position: fixed;
  font-size: 14px;
  text-align: center;
  right: 20px;
  top: 40%;


}
.social-links a{
    width: 6vw;
    height: 6vw;
    line-height: 25px !important;
    position: relative;
    margin: 15px 5px;
    text-align: center;
    display: list-item;
    list-style: none;
    color: #111;

    -webkit-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);  
    -moz-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
    -o-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);
    -ms-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
    transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);
}
.social-links a i,
.social-links a span{
    position: relative;
    top: 2px;
    left: 1px; 
}
.social-links a:before{
    content: "";
    display: list-item;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border: 1px solid #111;

    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    border-radius: 2px;

    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);

    -webkit-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);  
    -moz-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
    -o-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);
    -ms-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
    transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);

}
.social-links a:hover{
    color: #fff;
}
.social-links a:hover:before{
    background: #111;
}
<div class="social-links"><a href="#"></a></div>

Метод 2:
с использованием @ media

    @import url("//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css");


    /*Loghi dentro al rettangolo*/
    .social-links{
      position: fixed;
      font-size: 14px;
      text-align: center;
      right: 20px;
      top: 40%;


    }
    .social-links a{
        width: 25px;
        height: 25px;
        line-height: 25px !important;
        position: relative;
        margin: 15px 5px;
        text-align: center;
        display: list-item;
        list-style: none;
        color: #111;

        -webkit-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);  
        -moz-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
        -o-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);
        -ms-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
        transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);
    }
@media only screen and (max-width: 600px) {
    
    .social-links a{
        width: 15px;
        height: 15px;
        }
}
    .social-links a i,
    .social-links a span{
        position: relative;
        top: 2px;
        left: 1px; 
    }
    .social-links a:before{
        content: "";
        display: list-item;
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        border: 1px solid #111;

        -webkit-border-radius: 2px;
        -moz-border-radius: 2px;
        border-radius: 2px;

        -webkit-transform: rotate(45deg);
        -moz-transform: rotate(45deg);
        -o-transform: rotate(45deg);
        -ms-transform: rotate(45deg);
        transform: rotate(45deg);

        -webkit-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);  
        -moz-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
        -o-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);
        -ms-transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000); 
        transition: all 0.27s cubic-bezier(0.300, 0.100, 0.580, 1.000);

    }
    .social-links a:hover{
        color: #fff;
    }
    .social-links a:hover:before{
        background: #111;
    }
    <div class="social-links"><a href="#"></a></div>
...