How to wrap text around a div button? - html

Can anyone help me with wrapping of the text around the + box ? I can't seem to get it to work. I have a jfiddle that you can refer to. Hope anyone out there can assist me.
Here's the JSFiddle.
And here is the code:
.video-box {
float: left;
width: 31%;
max-width: 240px;
height: 214px;
background: #232323;
margin: 0 1% 2%;
}
.video-box h3 {
display: table-cell;
vertical-align: middle;
margin: 0;
font-size: 1.0em;
line-height: 1.2;
}
.addtoplaylist-videotext:before {
border: solid;
border-color: #222 transparent;
border-width: 6px 6px 0 6px;
bottom: -8px;
content: "";
left: 80%;
position: absolute;
display: inline-block;
z-index: 99;
border-top: 10px solid rgba(0, 0, 0, 0.6);
}
a {
color: #FFFFFF;
}
.video-txt {
position: absolute;
bottom: 0;
right: 0;
font-size: 1.1em;
line-height: 16px;
background: #000;
padding: 0 3px;
color: #fff;
}
.addtoplaylist-videotext {
background-color: #ffffff;
background-color: rgba(0, 0, 0, 0.6);
border-color: rgba(0, 0, 0, 0.6);
border-right-color: #ffffff;
border-radius: 5px;
top: -50px;
color: #ffffff;
left: -100px;
padding: 5px 5px;
position: relative;
z-index: 99;
width: 120px;
height: 15px;
text-align: center;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#1e78a0', endColorstr='#1e78a0');
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
cursor: pointer;
display: none;
}
.viewplaylist-videotext:before {
border: solid;
border-color: #222 transparent;
border-width: 6px 6px 0 6px;
bottom: -8px;
content: "";
left: 80%;
position: absolute;
display: inline-block;
z-index: 99;
border-top: 10px solid rgba(0, 0, 0, 0.6);
}
.viewplaylist-videotext {
background-color: #ffffff;
background-color: rgba(0, 0, 0, 0.6);
border-color: rgba(0, 0, 0, 0.6);
border-right-color: #ffffff;
border-radius: 5px;
top: -50px;
color: #ffffff;
left: -100px;
padding: 5px 5px;
position: relative;
z-index: 99;
width: 120px;
height: 15px;
text-align: center;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#1e78a0', endColorstr='#1e78a0');
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
cursor: pointer;
display: none;
}
.addtoplaylist-video:hover .addtoplaylist-videotext {
display: block;
}
.viewplaylist-video:hover .viewplaylist-videotext {
display: none;
}
.title {
color: #FFFFFF;
}
.maintainhere-browse {
float: right;
height: 30px;
margin-left: 3px;
margin-top: 20px;
position: relative;
}
.toggle2 {
position: relative;
float: right;
margin-right: 10px;
margin-top: -15px;
background-color: #f36666;
width: 20px;
height: 18px;
color: #FFFFFF;
font-size: 12px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
cursor: pointer;
font-weight: bold;
}
.addtoplaylist-video {
position: relative;
bottom: 0px;
right: 0px;
width: auto;
height: auto;
image-rendering: -moz-crisp-edges;
display: inline-block;
cursor: pointer;
}
.viewplaylist-video {
display: none;
}
}
.addtoplaylist-video a {
color: #FFFFFF !important;
}
.viewplaylist-video a {
color: #FFFFFF !important;
}
.play-ico {
background-position: -2px -1351px;
background: url(/blob/1086/1386905708000/a-ico-sprite-png-data.png) no-repeat -2px -1316px;
text-indent: -9999px;
position: absolute;
top: 0;
left: 0;
width: 33px;
height: 33px;
overflow: hidden;
text-align: left;
}
<div class="video-box">
<div class="video-box-content-holder" data-createtime="1385208101000" data-viewcounts="559">
<div class="img" style="max-height:135px">
<a href="/news/video/typhoon-haiyan-politics/897416.html">
<img src="http://i58.tinypic.com/2uj2o3t.jpg" alt="" width="240" height="135" />
<span class="play-ico">play</span>
<span class="video-txt">01:54</span>
</a>
<span class="add-txt">Asia Pacific</span>
</a>
</div>
<div class="txt-box">
<!-- the class toggle 2 is for 2nd component, diff css-->
<div class="maintainhere-browse">
<div id="browsevideos_1" class="toggle2">
<div class="addtoplaylist-video">
<img src="http://i61.tinypic.com/rtdv2b.png" width="12" height="11" alt="add" class="addplaylisticonimg-browse">
<span class="addtoplaylist-videotext"> Add To Playlist!</span>
</div>
<div class="viewplaylist-video">
<img src="http://i59.tinypic.com/2n98as.png" width="17" height="9" alt="viewicon" class="viewplaylisticonimg-browse">
<span class="viewplaylist-videotext"> View Playlist!</span>
</div>
</div>
</div>
<!--endofmaintainhere-->
<div class="title">
<h3 style="color:white;">Typhoon Haiyan: Politics gets in the way of saving lives i want the text to wrap around </h3>
<span class="date" style="color:white;">23 Nov 2013</span>
</div>
<!-- title -->
</div>
</div>
</div>

So the basic problem is assigning display: table to .video-box h3.
Once that is removed, it actually does wrap. The problem is now that you won't see it with that text, because it so happens that those words would move to the next line anyway. I've added more words and removed the height of the container and you can see this working:
DEMO showing text is wrapping without table-cell property.
In your case, I'd consider rewriting some of the code around positioning the .maintainhere-browse button:
.maintainhere-browse{
...
/*margin-top:20px; Remove this line */
...
}
.toggle2 {
...
margin-top: 10px; /* Changed this value */
...
}
Demo

Related

How to create a css hover effect for show button

I'm a beginner in programming, and I'm trying to create a card with a hover effect. When hovering over the card, I would like to add an opacity to the card and show 4 buttons, one above the other. Can you help me?
Below is my code.
.cardnew {
height : 256px;
text-align : center;
width : 246px;
background : #ffffff;
margin : 20px;
display : inline-block;
box-shadow : 1px 1px 22px rgba(157, 184, 209, 0.19);
border-radius : 1px;
cursor : pointer;
transition : 0.15s linear;
}
.cardnew > img {
height : 150px;
width : 100%;
border-radius : 10px 10px 0 0;
padding : 35px 0 5px 0;
}
.cardnew > h1 {
font-size : 22px;
color : #5c5c5c;
padding : 15px 0 5px 0;
font-weight : 100;
}
.cardnew > p {
font-size : 13px;
color : #cdcdcd;
padding : 0 40px;
line-height : 20px;
}
.cardnew > a {
padding : 13px;
font-weight : normal;
width : 260px;
color : #2687f1;
border : 2px solid #2687f1;
border-radius : 7px;
margin : auto;
margin-top : 35px;
display : block;
transition : 0.2s linear;
}
.cardnew:hover {
transform : scale(1.015);
transition : 0.15s linear;
box-shadow : 1px 1px 22px rgba(157, 184, 209, 0.5);
}
.cardnew:hover > a {
padding : 13px;
width : 260px;
color : #fff;
background : #2687f1;
border-radius : 7px;
margin : auto;
margin-top : 35px;
transition : 0.2s linear;
}
.row-card {
justify-content : space-around;
flex-wrap : wrap;
margin-right : -12.5px;
margin-left : -12.5px;
}
<div class="row-card">
<div class="cardnew">
<img src="https://enginehosting-html.fruitfulcode.com/wp-content/themes/enginehosting-html/assets/images/server.svg" style="padding: 60px 0 5px 0;height: 125px;" />
<h1>
name
</h1>
<p>firstname</p>
<div class="button"> BUTTON
<div class="button"> BUTTON
<div class="button"> BUTTON
<div class="button"> BUTTON
</div>
</div>
I tried some tutorials that I found on MDN and youtube but I couldn't implement it. Any help will be of great help.
can you help me?
like this pen: https://codepen.io/philcheng/pen/YWyYwG
The reason the styling for the buttons wasn't applied is because of all the >s you had. If you remove them, it seems to work a lot better. Also, you have a lot of divs that aren't closed at the bottom. Is there a reason for that?
For the disappearing, you can use the opacity property to make them disappear and reappear on hover.
.cardnew {
height: 256px;
text-align: center;
width: 246px;
background: #ffffff;
margin: 20px;
display: inline-block;
box-shadow: 1px 1px 22px rgba(157, 184, 209, 0.19);
border-radius: 1px;
cursor: pointer;
transition: 0.15s linear;
}
.cardnew img {
height: 150px;
width: 100%;
border-radius: 10px 10px 0 0;
padding: 35px 0 5px 0;
}
.cardnew h1 {
font-size: 22px;
color: #5c5c5c;
padding: 15px 0 5px 0;
font-weight: 100;
}
.cardnew p {
font-size: 13px;
color: #cdcdcd;
padding: 0 40px;
line-height: 20px;
}
.cardnew a {
padding: 13px;
font-weight: normal;
width: 260px;
color: #2687f1;
border: 2px solid #2687f1;
border-radius: 7px;
margin: auto;
margin-top: 35px;
display: block;
opacity: 0;
transition: 0.2s linear;
}
.cardnew:hover {
transform: scale(1.015);
transition: 0.15s linear;
box-shadow: 1px 1px 22px rgba(157, 184, 209, 0.5);
}
.cardnew:hover a {
padding: 13px;
width: 260px;
color: #fff;
background: #2687f1;
border-radius: 7px;
margin: auto;
margin-top: 35px;
opacity: 1;
transition: 0.2s linear;
}
.row-card {
justify-content: space-around;
flex-wrap: wrap;
margin-right: -12.5px;
margin-left: -12.5px;
}
<div class="row-card">
<div class="cardnew">
<img src="https://enginehosting-html.fruitfulcode.com/wp-content/themes/enginehosting-html/assets/images/server.svg" style="padding: 60px 0 5px 0;height: 125px;" />
<h1>
name
</h1>
<p>firstname</p>
<div class="button"> BUTTON
<div class="button"> BUTTON
<div class="button"> BUTTON
<div class="button"> BUTTON
</div>
</div>
EDIT:
I have messed around with your code, and I think I have created something like your picture.
(You might need to mess around with the values to get them perfect.)
.overlay {
background: rgba(0, 0, 0, 0.5);
height: 256px;
width: 246px;
position: absolute;
opacity: 0;
transition: 0.2s linear;
}
.cardnew a {
position: absolute;
padding: 13px;
font-weight: normal;
width: 160px;
color: #2687f1;
border: 2px solid #2687f1;
border-radius: 7px;
margin: auto;
margin-top: 35px;
display: block;
opacity: 0;
transition: 0.2s linear;
}
.cardnew:hover a {
transform: scale(1);
padding: 13px;
color: #fff;
background: #2687f1;
border-radius: 7px;
margin: auto;
margin-top: 35px;
opacity: 1;
transition: 0.2s linear;
}
.btn1 {
top: 10px;
left: 42.5px;
}
.btn2 {
top: 65px;
left: 42.5px;
}
.btn3 {
top: 120px;
left: 42.5px;
}
.btn4 {
top: 175px;
left: 42.5px;
}
.cardnew {
height: 256px;
text-align: center;
width: 246px;
background: #ffffff;
margin: 20px;
display: inline-block;
box-shadow: 1px 1px 22px rgba(157, 184, 209, 0.19);
border-radius: 1px;
cursor: pointer;
transition: 0.15s linear;
}
.cardnew img {
height: 150px;
width: 100%;
border-radius: 10px 10px 0 0;
padding: 35px 0 5px 0;
}
.cardnew h1 {
font-size: 22px;
color: #5c5c5c;
padding: 15px 0 5px 0;
font-weight: 100;
}
.cardnew p {
font-size: 13px;
color: #cdcdcd;
padding: 0 40px;
line-height: 20px;
}
..cardnew:hover {
transform: scale(1.015);
transition: 0.15s linear;
box-shadow: 1px 1px 22px rgba(157, 184, 209, 0.5);
}
.cardnew:hover .overlay {
opacity: 1;
}
.row-card {
justify-content: space-around;
flex-wrap: wrap;
margin-right: -12.5px;
margin-left: -12.5px;
}
<div class="row-card">
<div class="cardnew">
<div class='overlay'>
</div>
<img src="https://enginehosting-html.fruitfulcode.com/wp-content/themes/enginehosting-html/assets/images/server.svg" style="padding: 60px 0 5px 0;height: 125px;" />
<h1>
name
</h1>
<p>firstname</p>
<div class="button"> BUTTON </div>
<div class="button"> BUTTON </div>
<div class="button"> BUTTON </div>
<div class="button"> BUTTON </div>
</div>
</div>
Here is the codepen: click here

CSS button not aligning correctly

I have made this button by editing "Simple Hover Effect by Vincent Durand". But the problem is that some css in my blog is overlapping. So it is not aligning to middle correctly. I cant find which one it may be. I tried using !important tag in some places. But I guess it didn't work out. What I need to know where should I use !important in this code to align the button to middle? Or will I need a new css element to do that?
<!-- Awesome button css Start -->
.btn-margin {
margin-top: 1.6rem;
box-sizing: inherit;
text-align: center;
}
.btn {
-webkit-tap-high!importantr: transparent;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.14) 0 3px 3px 0, rgba(0, 0, 0, 0.12) 0 1px 7px 0, rgba(0, 0, 0, 0.2) 0 3px 1px -1px;
box-sizing: inherit;
color: white !important;
cursor: pointer;
display: inline-block;
height: auto;
letter-spacing: 0.5px;
line-height: 42px;
pointer-events: all;
position: relative;
text-decoration-line: none;
vertical-align: middle;
font-size: 1.6em;
padding: 0 2em;
transition: 800ms ease all;
}
.btn-green {
background-color: #1AAB8A;
}
.btn-green:hover {
background-color: #fff;
color: #1AAB8A !important;
}
.btn:before,.btn:after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 2px;
width: 0;
transition: 400ms ease all;
}
.btn:after {
right: inherit;
top: inherit;
left: 0;
bottom: 0;
}
.btn-green:before,.btn-green:after {
background: #1AAB8A;
}
.btn:hover:before,.btn:hover:after {
width: 100%;
transition: 800ms ease all;
}
<!-- Awesome button css End -->
<div class="btn-margin">
<a class="btn btn-green" href="#">
Click Here To See Answers
</a>
</div>
Add *{box-sizing:border-box;} to ur css
<!-- Awesome button css Start -->
*{box-sizing:border-box;}
.btn-margin {
margin-top: 1.6rem;
box-sizing: inherit;
text-align: center;
}
.btn {
-webkit-tap-high!importantr: transparent;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.14) 0 3px 3px 0, rgba(0, 0, 0, 0.12) 0 1px 7px 0, rgba(0, 0, 0, 0.2) 0 3px 1px -1px;
box-sizing: inherit;
color: white !important;
cursor: pointer;
display: inline-block;
height: auto;
letter-spacing: 0.5px;
line-height: 42px;
pointer-events: all;
position: relative;
text-decoration-line: none;
vertical-align: middle;
font-size: 1.6em;
padding: 0 2em;
transition: 800ms ease all;
}
.btn-green {
background-color: #1AAB8A;
}
.btn-green:hover {
background-color: #fff;
color: #1AAB8A !important;
}
.btn:before,.btn:after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 2px;
width: 0;
transition: 400ms ease all;
}
.btn:after {
right: inherit;
top: inherit;
left: 0;
bottom: 0;
}
.btn-green:before,.btn-green:after {
background: #1AAB8A;
}
.btn:hover:before,.btn:hover:after {
width: 100%;
transition: 800ms ease all;
}
<!-- Awesome button css End -->
<div class="btn-margin">
<a class="btn btn-green" href="#">
Click Here To See Answers
</a>
</div>
Use this CSS to center align the button
.btn-green {
background-color: #1AAB8A;
position: relative;
left: 50%;
transform: translateX(-50%);
}
<!-- Awesome button css Start -->.btn-margin {
margin-top: 1.6rem;
box-sizing: inherit;
position: relative;
left: 50%;
transform: translateX(-50%);
}
.btn {
-webkit-tap-high!importantr: transparent;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.14) 0 3px 3px 0, rgba(0, 0, 0, 0.12) 0 1px 7px 0, rgba(0, 0, 0, 0.2) 0 3px 1px -1px;
box-sizing: inherit;
color: white !important;
cursor: pointer;
display: inline-block;
height: auto;
letter-spacing: 0.5px;
line-height: 42px;
pointer-events: all;
position: relative;
text-decoration-line: none;
vertical-align: middle;
font-size: 1.6em;
padding: 0 2em;
transition: 800ms ease all;
}
.btn-green {
background-color: #1AAB8A;
position: relative;
left: 50%;
transform: translateX(-50%);
}
.btn-green:hover {
background-color: #fff;
color: #1AAB8A !important;
}
.btn:before,
.btn:after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 2px;
width: 0;
transition: 400ms ease all;
}
.btn:after {
right: inherit;
top: inherit;
left: 0;
bottom: 0;
}
.btn-green:before,
.btn-green:after {
background: #1AAB8A;
}
.btn:hover:before,
.btn:hover:after {
width: 100%;
transition: 800ms ease all;
}
<!-- Awesome button css End -->.btn-green {}
<div class="btn-margin">
<a class="btn btn-green" href="https://myneobuxportal.blogspot.com/p/answer-gamer-quiz-v2.html">
Click Here To See Answers
</a>
</div>
add one parent div and set this div text-align: center;
<!-- Awesome button css Start -->
.demo{
text-align: center;
}
.btn-margin {
margin-top: 1.6rem;
box-sizing: inherit;
text-align: center;
}
.btn {
-webkit-tap-high!importantr: transparent;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.14) 0 3px 3px 0, rgba(0, 0, 0, 0.12) 0 1px 7px 0, rgba(0, 0, 0, 0.2) 0 3px 1px -1px;
box-sizing: inherit;
color: white !important;
cursor: pointer;
display: inline-block;
height: auto;
letter-spacing: 0.5px;
line-height: 42px;
pointer-events: all;
position: relative;
text-decoration-line: none;
vertical-align: middle;
font-size: 1.6em;
padding: 0 2em;
transition: 800ms ease all;
}
.btn-green {
background-color: #1AAB8A;
}
.btn-green:hover {
background-color: #fff;
color: #1AAB8A !important;
}
.btn:before,.btn:after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 2px;
width: 0;
transition: 400ms ease all;
}
.btn:after {
right: inherit;
top: inherit;
left: 0;
bottom: 0;
}
.btn-green:before,.btn-green:after {
background: #1AAB8A;
}
.btn:hover:before,.btn:hover:after {
width: 100%;
transition: 800ms ease all;
}
<!-- Awesome button css End -->
<div class="Demo">
<div class="btn-margin">
<a class="btn btn-green" href="#">
Click Here To See Answers
</a>
</div>
</div>
In the end the problem was with the comment :(
I used html comment in css. That's why this happened. Thanks #CharuMaheshwari for mentioning that out. Also another thanks for other 3 answers. All of them worked.
With #CharuMaheshwari help this is the code I decided to use.
/* Awesome button css Start */
.btn-margin {
margin-top: 1.6rem;
box-sizing: inherit;
text-align: center;
}
.btn {
-webkit-tap-high!importantr: transparent;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.14) 0 3px 3px 0, rgba(0, 0, 0, 0.12) 0 1px 7px 0, rgba(0, 0, 0, 0.2) 0 3px 1px -1px;
box-sizing: inherit;
color: white !important;
cursor: pointer;
display: inline-block;
height: auto;
letter-spacing: 0.5px;
line-height: 42px;
pointer-events: all;
position: relative;
text-decoration-line: none;
vertical-align: middle;
font-size: 1.6em;
padding: 0 2em;
transition: 800ms ease all;
}
.btn-green {
background-color: #1AAB8A;
}
.btn-green:hover {
background-color: #fff;
color: #1AAB8A !important;
}
.btn:before,.btn:after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 2px;
width: 0;
transition: 400ms ease all;
}
.btn:after {
right: inherit;
top: inherit;
left: 0;
bottom: 0;
}
.btn-green:before,.btn-green:after {
background: #1AAB8A;
}
.btn:hover:before,.btn:hover:after {
width: 100%;
transition: 800ms ease all;
}
/* Awesome button css End */
<div class="btn-margin">
<a class="btn btn-green" href="#">
Click Here To See Answers
</a>
</div>

bug with safari when i used transform with perspective

I got this problem with safari browser when I used to transform with perspective to parent "parent". these blocks work well with chrome and Mozilla!
any help?
my code and a screenshot from safari below
enter image description here
.service-element {
text-align: center;
padding: 28px;
perspective: 298px;
position: absolute;
padding-left: 56px;
transition: all .5s ease-in-out;
padding-bottom: 60px;
padding-top: 60px;
}
.service-element:before {
content: '';
position: absolute;
right: 0;
bottom: 0;
left: 0;
top: 0;
z-index: -1;
background-color: #ffffff;
border: solid 0.5px #e3e0e0;
border-radius: 24px;
transition: all .5s ease-in-out;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.225);
-webkit-transform: rotateY(-10deg);
transform: rotateY(-10deg);
}
.service-element img {
height: 89px;
margin-bottom: 31px;
}
.service-element h2 {
font-size: 22px;
font-family: "indielabs-Frutiger-bold";
color: #4c4c4c;
}
.service-element .paragraph {
font-size: 14px;
color: #959595;
font-family: "indielabs-Frutiger-light";
}
<div class="service-element tr">
<img src="http://yehia.alyomhost.net/alyom-new/images/apps-icon#3x.jpg" class="img-fluid">
<h2>تصميم تطبيقات الجوال</h2>
<div class="paragraph">
لوريم ابيسوم نص عشواىي هنا يوضح الشكل وليس الهدف منه المحتوي
</div>

CSS: How to limit horizontal/vertical scrolling?

Details
I have made a div navigator for my website, there are 4 menu buttons which float left, and 1 authentication button which floats right. The navigators position is relative so it doesn't move.
CODE
body {
background-color: #2B2B2B;
}
.main {
position: relative;
top: 0%;
left: 0%;
right: 0%;
width: 101.6%;
height: 10%;
z-index: 1;
min-height: 120px;
max-height: 120px;
background-color: rgba(26, 26, 26, 0.9);
}
.logo {
display: block;
float: left;
top: 0%;
left: 0%;
right: 0%;
/*background-image: url('images/logo.png');
width: 150px;
height: 155px;*/
font-size: 32pt;
color: white;
margin-top: 3%;
margin-left: 1%;
}
.menu {
display: inline-block;
position: relative;
top: 0%;
left: 0%;
right: 0%;
background-color: rgba(26, 26, 26, 0.9);
height: 100%;
width: 101%;
border-style: solid;
border-color: rgba(26, 26, 26, 0.9);
border-radius: 0%;
z-index: 1;
max-height: 7%;
max-width: 102.5%;
min-height: 50px;
min-width: 100%;
overflow: hidden;
}
.Button1 {
display: block;
font-size: 10pt;
float: left;
right: 15%;
left: 30%;
top: 0%;
white-space: nowrap;
color: white;
margin-top: 0%;
width: 7%;
font-family: sans-serif;
height: 3%;
padding: 25px 2px 55px 2px;
vertical-align: center;
text-align: center;
line-height: 6px;
border-right: 1px solid rgba(0, 0, 0, 0.25);
border-left: 1px solid rgba(0, 0, 0, 0.25);
;
box-shadow: 1px 0 rgba(255, 255, 255, 0.03);
border-radius: 5px;
min-width: 70px;
transition: 0.1s ease-in;
-o-transition: 0.1s ease-in;
-ms-transition: 0.1s ease-in;
-moz-transition: 0.1s ease-in;
-webkit-transition: 0.1s ease-in;
}
.Button1:hover {
color: #C90205;
}
.Button2 {
font-size: 10pt;
float: left;
right: 10%;
left: 23%;
top: 10%;
white-space: nowrap;
color: white;
width: 7%;
margin-top: 0%;
font-family: sans-serif;
height: 3%;
text-align: center;
padding: 25px 0px 55px 0px;
text-align: center;
vertical-align: center;
line-height: 6px;
border-right: 1px solid rgba(0, 0, 0, 0.25);
border-left: 1px solid rgba(0, 0, 0, 0.25);
;
box-shadow: 1px 0 rgba(255, 255, 255, 0.03);
border-radius: 5px;
min-width: 70px;
transition: 0.1s ease-in;
-o-transition: 0.1s ease-in;
-ms-transition: 0.1s ease-in;
-moz-transition: 0.1s ease-in;
-webkit-transition: 0.1s ease-in;
}
.Button2:hover {
color: #C90205;
}
.Button3 {
font-size: 10pt;
float: left;
right: 10%;
left: 23%;
top: 3%;
white-space: nowrap;
color: white;
margin-top: 0%;
width: 7%;
font-family: sans-serif;
height: 3%;
text-align: center;
padding: 25px 0px 55px 0px;
text-align: center;
line-height: 6px;
border-right: 1px solid rgba(0, 0, 0, 0.25);
border-left: 1px solid rgba(0, 0, 0, 0.25);
;
box-shadow: 1px 0 rgba(255, 255, 255, 0.03);
border-radius: 5px;
min-width: 70px;
transition: 0.1s ease-in;
-o-transition: 0.1s ease-in;
-ms-transition: 0.1s ease-in;
-moz-transition: 0.1s ease-in;
-webkit-transition: 0.1s ease-in;
}
.Button3:hover {
color: #C90205;
}
.Button4 {
font-size: 10pt;
float: left;
right: 10%;
left: 23%;
top: 3%;
white-space: nowrap;
color: white;
margin-top: 0%;
width: 7%;
font-family: sans-serif;
height: 3%;
text-align: center;
padding: 25px 0px 55px 0px;
text-align: center;
line-height: 6px;
border-right: 1px solid rgba(0, 0, 0, 0.25);
border-left: 1px solid rgba(0, 0, 0, 0.25);
;
box-shadow: 1px 0 rgba(255, 255, 255, 0.03);
border-radius: 5px;
min-width: 70px;
transition: 0.1s ease-in;
-o-transition: 0.1s ease-in;
-ms-transition: 0.1s ease-in;
-moz-transition: 0.1s ease-in;
-webkit-transition: 0.1s ease-in;
}
.Button4:hover {
color: #C90205;
}
.Button5 {
font-size: 10pt;
float: left;
right: 10%;
left: 23%;
top: 3%;
white-space: nowrap;
color: white;
margin-top: 0%;
width: 7%;
font-family: sans-serif;
height: 3%;
text-align: center;
padding: 25px 0px 55px 0px;
text-align: center;
line-height: 6px;
border-right: 1px solid rgba(0, 0, 0, 0.25);
border-left: 1px solid rgba(0, 0, 0, 0.25);
;
box-shadow: 1px 0 rgba(255, 255, 255, 0.03);
border-radius: 5px;
min-width: 70px;
transition: 0.1s ease-in;
-o-transition: 0.1s ease-in;
-ms-transition: 0.1s ease-in;
-moz-transition: 0.1s ease-in;
-webkit-transition: 0.1s ease-in;
}
.Button5:hover {
color: #C90205;
}
.Button6 {
font-size: 10pt;
float: left;
right: 10%;
left: 23%;
top: 8%;
white-space: nowrap;
color: white;
margin-top: 0%;
font-family: sans-serif;
height: 10%;
width: 7%;
text-align: center;
height: 10%;
text-align: center;
padding: 28px 0px 55px 0px;
text-align: center;
line-height: 2px;
border-right: 1px solid rgba(0, 0, 0, 0.25);
border-left: 1px solid rgba(0, 0, 0, 0.25);
;
box-shadow: 1px 0 rgba(255, 255, 255, 0.03);
border-radius: 5px;
min-width: 70px;
transition: 0.1s ease-in;
-o-transition: 0.1s ease-in;
-ms-transition: 0.1s ease-in;
-moz-transition: 0.1s ease-in;
-webkit-transition: 0.1s ease-in;
}
.Button6:hover {
color: #C90205;
}
.signin {
float: right;
width: 114px;
height: 42px;
margin-top: 0.5%;
margin-right: 1.9%;
color: red;
}
.mainpage {
height: 100%;
width: 80%;
}
html,
body {
margin: 0;
padding: 0;
height: 100%;
width: 100%
}
<div class="main">
<a class="logo" href="/" style="text-decoration:none">My Website</a>
</div>
<div class="menu">
<a class="Button1" href="/" style="text-decoration:none">Button 1</a>
<a class="Button2" href="/" style="text-decoration:none">Button 2</a>
<a class="Button3" href="/" style="text-decoration:none">Button 3</a>
<a class="Button4" href="/" style="text-decoration:none">Button 4</a>
<a class="Button5" href="/support" style="text-decoration:none">Button 5</a>
<a class="Button5" href="/" style="text-decoration:none">Button 6</a>
<a class="signin" href="/login" style="text-decoration:none">AuthButton</a>
</div>
<div class="mainpage"></div>
<!-- This is page under the navigator for placing the content, right now it's empty -->
Fiddle.
Problem
Unfortunately if you look at this, and try to scroll horizontally you will see the overflow and it would just stay there, even though when I had the bottom content container mainpage div with the height of 100% and width of 80%, it would still be able to scroll down when there's nothing there at all.
As you see this code below, I have tried to limit html and body with specific resolution, which didn't fix my problem.
html, body {margin:0;padding:0;height:100%;width:100%}
Question
How could i limit my page from being scrolled in specific resolution only?
Can resolution be greater than value of 100% so it can work?
your problem is here:
.main {
width: 101.6%;
}
.mainpage {
height: 100%;
width: 80%;
}
I tweaked your code merging all those buttons classes into one. you had invalid/unused properties there.
you need to fix those properties mentioned above like this:
*,
*::before,
*::after {
box-sizing: border-box;
}
html,
body {
margin: 0;
height: 100%;
background-color: #2B2B2B
}
.main {
position: relative;
top: 0;
left: 0;
right: 0;
width: 100%;
height: 10%;
min-height: 120px;
max-height: 120px;
background-color: rgba(26, 26, 26, 0.9)
}
.logo {
float: left;
top: 0;
left: 0;
right: 0;
/*background-image: url('images/logo.png');
width: 150px;
height: 155px;*/
font-size: 32pt;
color: white;
margin: 3% 0 0 1%
}
.menu {
display: inline-block;
position: relative;
top: 0;
left: 0;
right: 0;
background-color: rgba(26, 26, 26, 0.9);
border: solid rgba(26, 26, 26, 0.9);
border-radius: 0;
z-index: 1;
min-height: 50px;
min-width: 100%
}
.Button {
font-size: 10pt;
float: left;
font-family: sans-serif;
padding: 25px 2px 55px;
border: solid rgba(0, 0, 0, 0.25);
border-width: 0 1px;
white-space: nowrap;
color: white;
width: 7%;
text-align: center;
line-height: 6px;
border-radius: 5px;
min-width: 70px;
transition: 0.1s ease-in;
text-decoration: none
}
.Button:hover {
color: #C90205;
}
.signin {
float: right;
width: 114px;
height: 42px;
margin-top: 0.5%;
margin-right: 1.9%;
color: red;
}
.mainpage {
height: calc(100% - 216px);
width: 100%;
}
<div class="main">
<a class="logo" href="/" style="text-decoration:none">My Website</a>
</div>
<div class="menu">
<a class="Button b1" href="/">Button 1</a>
<a class="Button b2" href="/">Button 2</a>
<a class="Button b3" href="/">Button 3</a>
<a class="Button b4" href="/">Button 4</a>
<a class="Button b5" href="/support">Button 5</a>
<a class="Button b6" href="/">Button 6</a>
<a class="signin" href="/login">AuthButton</a>
</div>
<div class="mainpage"></div>
<!-- This is page under the navigator for placing the content, right now it's empty -->
Another approach with smaller CSS can be seen here: https://jsfiddle.net/3125ygjf/3/
Perhaps you should also have a look at the flexbox-model. There you don't have to care about the absolute positioning. The container gets display: flex; flex-direction: column;and than you can place the header, menu and main in there. You just have give the main-div the needed hight and make it scrollable. That's it.
*edit: In addition all your buttons have a width of 7% i.e. This will cause trouble later on when you change the text for example. Try to avoid such width-values.
There are several things wrong in your code, I will list as many as I could notice:
div elements by default are 100% width, so you do not need to specify it. If you are trying to make some sort of hack using more than 100% because it is not fitting the whole x-axis of your viewport, something is wrong with your code.
A class serves as a multiple selector, meaning that you can just use one class for all your buttons if they all share the same CSS properties.
If you are defining max-height and min-height with the same value, why not just use height.
body has a margin by default in different browsers, generally it is around 8px, so you can remove it by using margin: 0.
Your main css property should always come after your vendor prefixes such as -webkit-, -moz-, etc.
When you use zero in your css properties, there is no need to specify px, pt, % or any other unit, since 0 will always be computed as 0px.
JSFiddle
CODE SNIPPET:
body {
background-color: #2B2B2B;
margin: 0
}
.main {
position: relative;
height: 10%;
z-index: 1;
height: 120px;
background-color: rgba(26, 26, 26, 0.9);
}
.logo {
display: block;
float: left;
/*background-image: url('images/logo.png');
width: 150px;
height: 155px;*/
font-size: 32pt;
color: white;
margin-top: 3%;
margin-left: 1%;
}
.menu {
position: relative;
background-color: rgba(26, 26, 26, 0.9);
height: 100%;
border-style: solid;
border-color: rgba(26, 26, 26, 0.9);
border-radius: 0;
z-index: 1;
height: 50px;
overflow: hidden;
}
.btn {
font-size: 10pt;
white-space: nowrap;
color: white;
float: left;
margin-top: 0;
width: 7%;
font-family: sans-serif;
padding: 25px 0 55px 0;
vertical-align: center;
text-align: center;
line-height: 6px;
border-right: 1px solid rgba(0, 0, 0, 0.25);
border-left: 1px solid rgba(0, 0, 0, 0.25);
box-shadow: 1px 0 rgba(255, 255, 255, 0.03);
border-radius: 5px;
min-width: 70px;
-o-transition: 0.1s ease-in;
-ms-transition: 0.1s ease-in;
-moz-transition: 0.1s ease-in;
-webkit-transition: 0.1s ease-in;
transition: 0.1s ease-in;
}
.btn:hover {
color: #C90205;
}
.signin {
float: right;
width: 114px;
height: 42px;
margin-top: 0.5%;
margin-right: 1.9%;
color: red;
}
.mainpage {
height: 100%;
}
<div class="main">
<a class="logo" href="/" style="text-decoration:none">My Website</a>
</div>
<div class="menu">
<a class="btn" href="/" style="text-decoration:none">Button 1</a>
<a class="btn" href="/" style="text-decoration:none">Button 2</a>
<a class="btn" href="/" style="text-decoration:none">Button 3</a>
<a class="btn" href="/" style="text-decoration:none">Button 4</a>
<a class="btn" href="/support" style="text-decoration:none">Button 5</a>
<a class="btn" href="/" style="text-decoration:none">Button 6</a>
<a class="signin" href="/login" style="text-decoration:none">AuthButton</a>
</div>
<div class="mainpage"></div>
<!-- This is page under the navigator for placing the content, right now it's empty -->

Why background is blinking on hover when I move mouse cursor in DP box

I am trying to create a DP box for the user which is containing a user profile picture in it, where on image hover an edit profile image link will appear, but it is not working. When I hover over on the image it is blinking and the link doesn't appear correctly.
Here is the codepan link click here
#import url(https://fonts.googleapis.com/css?family=Roboto);
body {
font-family: 'Roboto', sans-serif;
background-color: #eee;
}
.dp {
width: 128px;
height: 128px;
margin: 0 auto;
border-radius: 50%;
border: 4px solid #fff;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.52);
overflow: hidden;
position: relative;
}
.edit-dp a {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
line-height: 130px;
background-color: rgba(0, 0, 0, .9);
text-align: center;
transition: all .2s ease-in-out;
color: #fff;
font-size: 15px;
text-decoration: none;
display: none;
}
.dp img:hover ~ .edit-dp a {
display: block;
}
<div class="dp">
<img src="http://rs618.pbsrc.com/albums/tt265/davejarrett/Avatars/check-in-minion_zps7ee060ac.jpg~c200" alt="" width="128">
<div class="edit-dp">
Edit Image
</div>
</div>
The blinking glitch is because of that :hover effect of display: block on image instead of container div.
Since every time you :hover on the image you ultimately gonna edit it, so instead of display: none you can set it to opacity: 0 and on :hover you can set it to opacity: 1 and by doing this you'll get a nice transition effect too.
Here's the Snippet for a better view:
#import url(https://fonts.googleapis.com/css?family=Roboto);
body {
font-family: 'Roboto', sans-serif;
background-color: #eee;
}
.dp {
width: 128px;
height: 128px;
margin: 0 auto;
border-radius: 50%;
border: 4px solid #fff;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.52);
overflow: hidden;
position: relative;
}
.edit-dp a {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
line-height: 130px;
background-color: rgba(0, 0, 0, .9);
text-align: center;
color: #fff;
font-size: 15px;
text-decoration: none;
opacity: 0;
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}
.dp:hover .edit-dp a {
opacity: 1;
}
<div class="dp">
<img src="http://rs618.pbsrc.com/albums/tt265/davejarrett/Avatars/check-in-minion_zps7ee060ac.jpg~c200" alt="" width="128">
<div class="edit-dp">
Edit Image
</div>
</div>
Solution 1:
Use following css will make your effect nice.
.dp:hover > .edit-dp a{
display: block;
}
Make hover effect on div instead of image
#import url(https://fonts.googleapis.com/css?family=Roboto);
body {
font-family: 'Roboto', sans-serif;
background-color: #eee;
}
.dp {
width: 128px;
height: 128px;
margin: 0 auto;
border-radius: 50%;
border: 4px solid #fff;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.52);
overflow: hidden;
position: relative;
}
.edit-dp a {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
line-height: 130px;
background-color: rgba(0, 0, 0, .9);
text-align: center;
transition: all .2s ease-in-out;
color: #fff;
font-size: 15px;
text-decoration: none;
display: none;
}
.dp:hover > .edit-dp a{
display: block;
}
<div class="dp">
<img src="http://rs618.pbsrc.com/albums/tt265/davejarrett/Avatars/check-in-minion_zps7ee060ac.jpg~c200" alt="" width="128">
<div class="edit-dp">
Edit Image
</div>
</div>
Working Codepen
Solution 2:
And Another solution is use pointer-events:none; on hover.
.dp img:hover ~ .edit-dp a{
display: block;
pointer-events:none;
}
Working Codepen