2017-02-21 43 views
0

我的问题是这个代码,当我使它响应时,它不起作用..我知道改变高度和宽度必须在百分比中转换,但是当我使它响应时,这个代码被破坏..如何使这个代码响应

此代码*的CSS(我想将其改造成响应):

@import url(http://weloveiconfonts.com/api/?family=entypo); 

/* entypo */ 
[class*="entypo-"]:before { 
    font-family: 'entypo', sans-serif; 
} 




.entry{ 
    width:430px; 
    position: RELATIVE; 
    top:600PX; 
    LEFT: 5PX; 
    margin:50px auto; 
    border-radius:50%; 
    float:left; 

} 


.container{ 
    width:110px; 
    height:110px; 
    margin:0 0 30px 10px; 
    position:relative; 
    border-radius:60px; 
    background:rgba(255,255,255,.2); 
    box-shadow:3px 3px 5px rgba(0,0,0,.2); 
    transition:all .5s; 
    overflow:hidden; 

} 

.photo{ 
    width:90px; 
    height:90px; 
    margin:8px; 
    border-radius:50%; 
    position:absolute; 
    left:0px; 
    overflow:hidden; 
    border:2px solid white; 
} 

.pic{ max-width:100%; } 

.button{ 
    width:60px; 
    height:60px; 
    position:absolute; 
    right:20px; 
    top:25px; 
    font-size:40px; 
    text-align:center; 
    line-height:60px; 
    border-radius:50%; 
    color:rgba(255,255,255,.8); 
    background:green; 
    background:linear-gradient(bottom,#5ca321,#8ab24f); 
    box-shadow:0 0 0 1px rgba(0,0,0,.2), 
      0 0 0 5px rgba(255,255,255,.1), 
      0 0 0 6px rgba(0,0,0,.2); 
    transition:all .5s; 
    cursor:pointer; 
} 
.button:hover{ 
    background:#5ca321; 
    box-shadow:inset 0 1px 5px rgba(0,0,0,.3); 
    text-shadow:0px 0px 5px gray; 
} 

.name{ 

    height:60%; 
    width:180px; 
    position:absolute; 
    right:80px; 
    padding:20px; 
    font:25px arial; 
    color:white; 
    opacity:0; 
    transition:all .5s .5s; 
    text-shadow:0 0 5px rgba(0,0,0,.5); 
} 

.small{ font-size:14px; display:block; margin-top:10px; } 

.comment{ 
    width:370px; 
    position:relative; 
    padding:15px; 
    font-size:16px; 
    color:rgba(0,0,0,.7); 
    border-radius:10px; 
    background:rgba(255,255,255,.4); 
    box-shadow:3px 3px 5px rgba(0,0,0,.2); 
    opacity:0; 
    transition:all 1s; 
} 

.comment:before{ 
    content:''; 
    width:0; 
    height:0; 
    position:absolute; 
    bottom:100%; 
    left:2%; 
    border-bottom:15px solid rgba(255,255,255,.4); 
    border-left:50px solid transparent; 
    border-right:50px solid transparent; 
    border-top:15px solid transparent; 

} 

.container:hover{ width:400px; } 

.container:hover .name,.container:hover + .comment{ 
    opacity:1; 
} 

也许你需要看一下演示 https://codepen.io/GARDFIELD3/pen/zNgmMP 我想这样做RESP对这个大小和位置感兴趣感谢并忽略我的言语错误,但我不会说英语:)

+0

欢迎堆栈溢出!请在问题中提供[mcve]中的所有相关代码,而不要在第三方网站上提供。 –

回答

2

由于在CSS中没有媒体查询,因此它没有响应。截至目前,您的代码将无论运行的屏幕尺寸,但让我们说,你想看看不同的手机,那么你会做这样的事情:

@media screen and (max-width: 420px) { 

    /* put in different CSS code here */ 

} 
+0

因此,如果在CSS中添加此代码将变得接受而不改变任何东西?我是一个初学者说我更多请:)我想让接受所有设备:) – sLOBOZ

+0

你将不得不编写新的代码,因为你使用绝对像素大小,这不给你很大的灵活性。例如,您的'.entry'的硬件宽度为430像素,但明显大于大约420像素的手机屏幕,因此您将拥有悬停在边缘的内容,这会为您提供侧滚动条和没人愿意。如果你使用百分比代替,你可能已经能够避免变化很多,但是因为你没有......你将不得不编写新的代码。 – Slime

+0

以及我不能修改制作响应而不做一个新的?如何转换这些像素的百分比? – sLOBOZ

0

您需要使用媒体查询和目标无论您想要更改哪个元素。

例如:

@media screen and (min-width: 767px) { 
.entry { 
    margin-top: 100px; 
} 
} 

这将在一个100像素的margin-top添加到您的.entry类宽度等于或大于767px更大的屏幕。

Read more/take a tutorial作为介绍。

+0

请为我编辑的代码,因为我只明白具体的例子,请允许我给我时间,请帮我.. – sLOBOZ

0

这更接近你想要达到的目标吗?

我已将commententry的宽度设置为100%,因为您可能希望这两个div标签都展开为文档的整个宽度。

尽管确实宽度是相对于文档的,但这并不意味着这是responsive design。响应式设计保持viewport的重要性。尝试使用Google搜索。你的语言中没有教程是不太可能的。

@import url(http://weloveiconfonts.com/api/?family=entypo); 
 
@media screen and (max-width: 420px) { 
 
/* entypo */} 
 
[class*="entypo-"]:before { 
 
    font-family: 'entypo', sans-serif; 
 
} 
 

 

 

 

 
.entry{ 
 
    width:100%; 
 
    position: RELATIVE; 
 
    top:60PX; 
 
    LEFT: 5PX; 
 
    margin:50px auto; 
 
    border-radius:50%; 
 
    float:left; 
 

 
} 
 

 

 
.container{ 
 
    position:relative; 
 
    width:110px; 
 
    height:110px; 
 
    margin:0 0 30px 10px; 
 
    
 
    border-radius:60px; 
 
    background:rgba(255,255,255,.2); 
 
    box-shadow:3px 3px 5px rgba(0,0,0,.2); 
 
    
 
    transition:all .5s; 
 
    overflow:hidden; 
 
} 
 

 
.photo{ 
 
    width:90px; 
 
    height:90px; 
 
    margin:8px; 
 
    border-radius:50%; 
 
    position:absolute; 
 
    left:0px; 
 
    overflow:hidden; 
 
    border:2px solid white; 
 
} 
 

 
.pic{ max-width:100%; } 
 

 
.button{ 
 
    width:60px; 
 
    height:60px; 
 
    position:absolute; 
 
    right:20px; 
 
    top:25px; 
 
    font-size:40px; 
 
    text-align:center; 
 
    line-height:60px; 
 
    border-radius:50%; 
 
    color:rgba(255,255,255,.8); 
 
    background:green; 
 
    background:linear-gradient(bottom,#5ca321,#8ab24f); 
 
    box-shadow:0 0 0 1px rgba(0,0,0,.2), 
 
      0 0 0 5px rgba(255,255,255,.1), 
 
      0 0 0 6px rgba(0,0,0,.2); 
 
    transition:all .5s; 
 
    cursor:pointer; 
 
} 
 
.button:hover{ 
 
    background:#5ca321; 
 
    box-shadow:inset 0 1px 5px rgba(0,0,0,.3); 
 
    text-shadow:0px 0px 5px gray; 
 
} 
 

 
.name{ 
 
    
 
    height:60%; 
 
    width:180px; 
 
    position:absolute; 
 
    right:80px; 
 
    padding:20px; 
 
    font:25px arial; 
 
    color:white; 
 
    opacity:0; 
 
    transition:all .5s .5s; 
 
    text-shadow:0 0 5px rgba(0,0,0,.5); 
 
} 
 

 
.small{ font-size:14px; display:block; margin-top:10px; } 
 

 
.comment{ 
 
    width:100%; 
 
    position:relative; 
 
    padding:15px; 
 
    font-size:16px; 
 
    color:rgba(0,0,0,.7); 
 
    border-radius:10px; 
 
    background:rgba(255,255,255,.4); 
 
    box-shadow:3px 3px 5px rgba(0,0,0,.2); 
 
    opacity:0; 
 
    transition:all 1s; 
 
} 
 

 
.comment:before{ 
 
    content:''; 
 
    width:0; 
 
    height:0; 
 
    position:absolute; 
 
    bottom:100%; 
 
    left:2%; 
 
    border-bottom:15px solid rgba(255,255,255,.4); 
 
    border-left:50px solid transparent; 
 
    border-right:50px solid transparent; 
 
    border-top:15px solid transparent; 
 
    
 
} 
 

 
.container:hover{ width:100%; } 
 

 
.container:hover .name,.container:hover + .comment{ 
 
    opacity:1; 
 
}
<div class="entry"> 
 
    
 
    <div class="container">  
 
    <div class="button entypo-chat"></div> 
 
    <div class="name">CoStY 
 
     <span class="small">Fondator</span>  
 
    </div> 
 
    <div class="photo"> 
 
     <img src="https://s12.postimg.org/pptidy8kd/14021445_1166695373388266_2759142_n.jpg" alt="" class="pic"> 
 
    </div> 
 
    </div> 
 
    
 
    <p class="comment">Salut, numele meu este Enache Constantin si sunt creatorul acestei comunitati :) Puteti sa ajutati la intretinerea comunitatii printr-o donatie ,pm pentru detalii :) </p> 
 
    
 
</div> 
 

 
<div class="entry"> 
 
    
 
    <div class="container">  
 
    <div class="button entypo-chat"></div> 
 
    <div class="name">Gardfield<3 
 
     <span class="small">Administrator</span>  
 
    </div> 
 
    <div class="photo"> 
 
     <img src="http://farm1.staticflickr.com/133/378977890_40f31e1962_q.jpg" alt="" class="pic"> 
 
    </div> 
 
    </div> 
 
    
 
    <p class="comment">Salut,numele meu este Alexandru Mihai iar misiunea mea este sa dezvolt aceasta comunitate din toate punctele de vedere. Sunt deschis la orice colaborare si ma puteti contacta pentru probleme tehnice printr-un pm :) </p> 
 
    
 
</div>

+0

是接近真相的位置,但没有作为大小..我想很好地看到任何分辨率..你认为你可以这样做吗?我也是初学者我明白我怎么能做到这一点 – sLOBOZ

+0

恐怕你要求的是一个答案太宽泛。你不能用你的语言找到任何文档吗?例如[本网站](https://www.w3schools.com/html/html_responsive.asp)。点击地球图标(右上角)翻译成罗马尼亚语:) – DerpyNerd

+0

我尊重你,你已经做出了响应的位置,但我想在响应中改变大小..变换widht,高度在procent我认为这将使响应大小..你明白我在找什么,如果你这样做,你会听到赢家.. – sLOBOZ