I've made 2 boxes that are blue and have a white text color, and when you hover over them, the text color changes from white to blue and the box color changes from blue to white. That part works. But when I hover below the text from the box, the text color changes back to blue even though I'm still with my mouse on the box 'href'.
Have a look at my code:
body {
background: #DCDCDC
}
a {
text-decoration: none;
}
#galaxy {
width: 400px;
height: 300px;
background-color: rgba(37, 100, 165, 0.80);
border: 1px solid rgba(37, 100, 165, 0.80);
margin: 0 auto;
margin-top: 100px;
color: white;
font-size: 30px;
border-radius: 10px;
}
#galaxy:hover {
background-repeat: no-repeat;
background-color: #FFF;
}
#test {
width: 400px;
height: 300px;
background-color: rgba(37, 100, 165, 0.80);
border: 1px solid rgba(37, 100, 165, 0.80);
margin: 0 auto;
margin-top: 100px;
color: white;
font-size: 30px;
border-radius: 10px;
}
#test:hover {
background-repeat: no-repeat;
background-color: #F00;
}
.button-title-text {
text-align: center;
color: #FFF;
font-size: 16px;
padding-top: 100px;
}
.button-title-text:hover {
text-align: center;
color: rgb(37, 100, 165);
font-size: 16px;
padding-top: 100px;
}
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<a href="#">
<div id="galaxy">
<div class="button-title-text">
<h1>Galaxy</h1>
</div>
</div>
</a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<a href="#">
<div id="test">
<div class="button-title-text">
<h1>test</h1>
</div>
</div>
</a>
</div>
Any help would be appreciated. Thanks in advance.
Consolidated your code and fixed the issue.
You had identical styles for your #galaxy and #test boxes (until they're hovered). I added a class called .box to both of them and moved the styles to that selector.
The issue in your post was occurring because you had a :hover rule on the box itself and the text inside. The hover on the text was behaving as written - it was only activating when you hovered directly over the text.
To fix this, I removed the color: attribute from your .button-title-text element, allowing it to inherit the color from the .box.
Then I added a .box:hover rule that changes the text color, which takes effect when either box is hovered.
Hope this helps!
body {
background: #DCDCDC
}
a {
text-decoration: none;
}
.box {
width: 400px;
height: 300px;
background-color: rgba(37, 100, 165, 0.80);
border: 1px solid rgba(37, 100, 165, 0.80);
margin: 0 auto;
margin-top: 100px;
color: white;
font-size: 30px;
border-radius: 10px;
}
.button-title-text {
text-align: center;
font-size: 16px;
padding-top: 100px;
}
.box:hover {
background-color: #FFF;
color: rgb(37, 100, 165);
}
#test:hover {
background-color: #F00;
}
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<a href="#">
<div id="galaxy" class="box">
<div class="button-title-text">
<h1>Galaxy</h1>
</div>
</div>
</a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<a href="#">
<div id="test" class="box">
<div class="button-title-text">
<h1>test</h1>
</div>
</div>
</a>
</div>
Related
So, i have some <p> tag and a text in it, and it's positioned to the left of the button. If the text keeps getting bigger, the button keeps being pushed to the right. I want to position all the buttons in the bottom-right corner of every div. Here's my HTML:
#dugme {
font-weight: bold;
left: 15vw;
line-height: 2vw;
color: white;
background-color: rgb(17, 142, 146);
text-align: center;
border: white 2px solid;
}
#dugme:hover{
background-color: aliceblue;
color: rgb(17, 142, 146);
}
#stripovi {
padding-top: 2em;
margin-bottom: 1em;
margin-left: 10px;
}
#comic {
display: inline-block;
background-color: rgb(230, 200, 119);
border-radius: 3px;
margin-right: 15px;
margin-top: 5px;
margin-bottom: 5px;
}
.naziv {
font-family: 'Fredoka One', cursive;
float: right;
margin-top: 100px;
word-wrap: break-word;
margin-top: auto;
margin-left: auto;
}
.container-fluid{
background-color: rgb(74, 198, 202);
}
<div class="row" id="stripovi">
<div class="comic w-50">
<div class="comic-img-top d-flex align-items-center form-group" id="comic">
<div class="thumbnail">
<img class="img-responsive" src="slike/c1.jpg" alt="comicbook">
<div class="naziv">
<p class="col p-2 m-0">Heavy Metal Comic</p>
<p class="col p-2 m-0" style="color: rgb(155, 151, 151); text-align: left;">ID:0101</p>
</div>
</div>
<div class="form-group">
<button type="button" class="btn btn-info" id="dugme">Dodaj</button>
</div>
</div>
</div>
<div class="comic w-50">
<div class="comic-img-top d-flex align-items-center form-group" id="comic">
<div class="thumbnail">
<img class="img-responsive" src="slike/c2.jpg" alt="comicbook">
<div class="naziv">
<p class="col p-2 m-0">Deadly Class</p>
<p class="col p-2 m-0" style="color: rgb(155, 151, 151); text-align: left;">ID:0101</p>
</div>
</div>
<div class="form-group">
<button type="button" class="btn btn-info" id="dugme">Dodaj</button>
</div>
</div>
</div>
</div>
This is what the buttons look like.As you can see in the second comic, the text moved the button to the right. I want to make the button remain in the same position for every product, and that position would be the bottom right corner of this rectangle.
Thank you in advance!
You can add
position: relative to comic-img-top
remove the id="comic" and instead use classes. ID should be unique, so you shouldn't repeat it.
Add another custom class to form-group, the container which holds the button.
CSS
position: absolute;
bottom: 0;
right: 0;
This will give you the desired result
#comic { // Make this a class and not an ID if it is going to be repeated
position: relative;
}
.form-group.new-button-container-class{
position: absolute;
bottom: 0;
right: 0;
}
<HTML>
<div class="form-group new-button-container-class">
<button type="button" class="btn btn-info" id="dugme">Dodaj</button>
</div>
Add a
position: absolute;
This makes your element stay on a position. Therefore this function is called absolute. The position property specifies the type of positioning method used for an element (static, relative, absolute, fixed, or sticky). It's syntax is to be used as position: static|absolute|fixed|relative|sticky|initial|inherit;. Or if you like to use the javascript approach:
object.style.position="absolute"
For total use change:
#dugme {
font-weight: bold;
left: 15vw;
line-height: 2vw;
color: white;
background-color: rgb(17, 142, 146);
text-align: center;
border: white 2px solid;
}
to:
#dugme {
font-weight: bold;
left: 15vw;
line-height: 2vw;
color: white;
background-color: rgb(17, 142, 146);
text-align: center;
border: white 2px solid;
position: absolute;
}
Now everything you need to do is just align everything right.
I made 3 div elements name cont1 cont2 and cont3 all of them have their own paragraph and header inside, I made something like animation so whoever hovers one of those conts box-shadow gets higher and the scale of div increases but the problem is that if display is inherit and someone for example hovers first div other 2 divs which are down also move
#main div {
display: inherit;
position: relative;
}
#main div button {
margin-top: 120px;
width: 140px;
height: 70px;
background: #49587a;
border: none;
border-radius: 15px;
box-shadow: 2px 4px #2d3342;
transition: 0.2s;
font-weight: 600;
font-size: 1.2rem;
color: #e4f9e0;
cursor: pointer;
}
#cont1,
#cont2,
#cont3 {
width: 290px;
height: 600px;
background: rgb(30, 33, 33, 0.85);
margin-top: 15vh;
margin-left: 10vw;
border-radius: 25px;
transition: 0.35s;
color: white;
text-align: center;
box-shadow: 5px 10px #0c0921;
}
#cont1:hover,
#cont2:hover,
#cont3:hover,
#cont4:hover {
transform: scale(1.05);
height: 620px;
box-shadow: 15px 20px #0c0921;
}
<div id="main">
<div id="cont1">
<h1>Basic</h1>
<p>Buy <span>Basic</span> packet and get:</p>
<p>300 Minutes Talk</p>
<p>500 SMS</p>
<p>5GB NET More info</p>
<button>Buy Now !</button>
</div>
<div id="cont2">
<h1>Premium</h1>
<p>Buy <span>Basic</span> packet and get:</p>
<p><span>1000</span> Minutes Talk</p>
<p>500 SMS</p>
<p>12GB NET</p>
<button>Buy Now !</button>
</div>
<div id="cont3">
<h1>Pro</h1>
<p>Buy <span>Basic</span> packet and get:</p>
<p><span style="">ULIMITED</span> Minutes Talk</p>
<p><span>UNLIMITED</span> SMS</p>
<p>25GB NET</p>
<button>Buy Now !</button>
</div>
<div id="asd">
<p>Lorem Ipsum</p>
</div>
<input>asd
<button id="btn">add</button>
</div>
Just Remove:
#cont1:hover,#cont2:hover,#cont3:hover,#cont4:hover,{
height: 620px;
}
Codepen (removed line is line 42)
I have an issue with my divs. Whenever I add a border to div, there is some gap inside of divs image. It has 0 margins and 0 padding. Image link: https://imgur.com/a/ojppCWU
There is no border gap and outline gap is added for them. Also there is no extra border, margins and padding is added inside div contents.
I have attached the live link of page in case if you didn't found a bug from my snippet. You can review the live code here: https://10xplusmedia.com/seo-services/finalproject/pageold1.html
I have tried to add border-collapse, but it didn't work. But when I add outline, gap is gone but there is no chance to add border-radius. I need border-radius anyway. So finding a solution for gap though.
There should be no gap if possible.
body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 1.4285;
color: #333;
background-color: #fff;
}
body {
font-family: arial;
font-size: 16px;
}
html {
font-family: sans-serif;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
html {
font-size: 10px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
html {
height: 100%;
}
.pageold__1__main__div {
border: 1px solid black;
border-radius: 0;
overflow: hidden;
}
.fgf {
background-color: #e6e7e9;
}
.eco__eff_1 {
overflow: hidden;
}
p {
margin: 0 0 10px;
}
.stg-cs-a {
margin: 14px 0 !important;
}
.lge p {
margin: 15px;
color: white;
}
.hj p {
font-size: 14px;
color: #233346;
}
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0px;
font-size: 14px;
font-weight: 400;
line-height: 1.4285;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.btn-primary {
color: #fff;
background-color: #337ab7;
border-color: #2e6da4;
}
.btn-group-sm > .btn, .btn-sm {
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
.form-control, .btn {
padding: 10px 12px;
height: auto;
font-size: 14px;
border-radius: 5px;
}
.btn {
border-radius: 5px;
}
.btn-sm {
padding: 3px 10px;
}
.hj button {
color: #ffffff;
text-shadow: 0px -1px 0px rgba(0,0,0,0.25);
background-image: url("assets/images/bu.jpg");
background-position: left center;
}
b, strong {
font-weight: 700;
}
.stg {
font-size: 8px;
}
.stg-cs-a .stg {
font-size: 11px !important;
font-weight: bold;
display: block;
padding: 5px 0px;
}
.stg-cs-a .stg {
font-size: 8px !important;
font-weight: bold;
display: block;
padding: 5px 0px;
}
.c__dd__1 {
padding-right: 0px;
}
.lang {
font-size: 16px;
color: #6e7076;
margin-left: 40px;
margin-top: 25px;
}
.langs {
font-size: 16px;
color: #6e7076;
margin-left: 40px;
}
.langss {
margin-left: 30px;
}
.mggpp__opo {
margin-left: 0px;
}
img {
border: 0;
}
img {
vertical-align: middle;
}
.mggpp__opo img {
width: 30px !important;
}
.w_100_cs__a {
width: 100% !important;
}
.bg_img_div__o {
background: #2F518B;
overflow: hidden;
}
.headeR__Page__old__1 {
color: white;
margin: 0;
padding: 20px 0;
}
<div class="pageold__1__main__div">
<div>
<div class="bg_img_div__o">
<div class="col-md-3 col-sm-3">
<p class="headeR__Page__old__1"><b>Booking ID:</b> EC4A7305</p>
</div>
<div class="col-md-6 col-sm-6">
<p class="headeR__Page__old__1"><b>Booking Date:</b> Montag, 27. Jan. 2018 - Dienstag, 28. Jan. 2018</p>
</div>
<div class="col-md-3 col-sm-3">
<p class="headeR__Page__old__1"><b>Booking Period:</b> 2Tage</p>
</div>
</div>
</div>
<div class="content__pageone_div">
<div class=" ">
<div class="row">
<div class=" col-sm-3 c__dd__1">
<img class="w_100_cs__a" alt="" src="assets/images/gg.JPG">
</div>
<div class="col-sm-9 c__dd__2">
<p class="lang mggpp__opo"><b> Langeoog,</b> Höhenpromenade 1, 26465 Langeoog</p>
<p class="langs mggpp__opo"><b> Öffnungszeiten:</b> 7:00 - 19:00 Uhr</p>
<p class="langss mggpp__opo"> <img style=" width: 40px;" alt="" src="assets/images/i0.JPG">
<img style=" width: 40px;
margin-top: -1px;" alt="" src="assets/images/i2.JPG">
<img style=" width: 40px;" alt="" src="assets/images/i3.JPG">
<img style=" width: 41px;" alt="" src="assets/images/i4.JPG">
<img style=" width: 41px;" alt="" src="assets/images/i5.JPG">
<img style=" width: 41px;" alt="" src="assets/images/i6.JPG">
<img style=" width: 44px;" alt="" src="assets/images/i7.JPG">
<img style=" width: 41px;" alt="" src="assets/images/i8.JPG">
<img style=" width: 41px;" alt="" src="assets/images/i9.JPG">
</p>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="lge fgf eco__eff_1">
<div class="col-md-3 col-sm-6 hj">
<p><b>Sie haben gewählt:</b><br>2x Strandkorb</p>
</div>
<div class="col-md-3 col-sm-6 hj">
<p><b>Standort:: </b><br>Strandabschnitt: 105<br>Strandkorb: 471, 462</p>
</div>
<div class="col-md-3 col-sm-6">
<div class="row">
<div class="col-sm-6 hj">
<p><b>Strandkorb: </b><br>471 / 2 Tage<br>462 / 2 Tage</p>
</div>
<div class="col-sm-6 hj">
<p><br>21,98 EUR<br>21,98 EUR</p>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6" style=" background-color: #FFB506;">
<div class="row hj">
<div class="col-sm-7 col-xs-4">
<p class="stg-cs-a"><b>Gesamtsumme: </b><br><span class="stg"> inkl. Steuern & Gebühren <br>(inkl. 0.99 € Nutzungsentgeld pro Tag StandKorb)</span></p>
</div>
<div class=" col-xs-4"></div>
<div class="col-sm-5 col-xs-4">
<p><b>43,96 EUR</b></p>
<button class="btn btn-primary btn-sm" type="button">Stornieren</button>
<br><br>
</div>
</div>
</div>
</div>
</div>
</div>
Your images have a white edge in them. Use image editing software to crop it out.
Edit:
I don't see any gaps as indicated in your screenshot.
Left is Chrome 71 and right is Firefox 65 Dev Edition both on MacOS 10.14
If it's not the image try this and see if it works:
body, html {
margin: 0px;
padding: 0px;
}
I have a button near the bottom of the page that is centered. Additionally, I have three images that I centered by making each image a col-lg-2 with 3 empty columns in between each one. I cannot figure out why these two items don't line up nicely, and which one is the one that is off center.
https://codepen.io/colesam/full/OgamyB/
SCSS:
a {
color: $blue;
font-size: 1.4vw;
font-weight: 500;
line-height: 1.7vw;
transition: all 0.2s;
&:hover {
color: $orange;
font-size: 1.7vw;
cursor: pointer;
text-decoration: none;
}
&:focus {
color: $blue;
text-decoration: none;
&:hover {
color: $orange;
cursor: pointer;
}
}
}
body {
background: white;
color: $black;
font-family: 'Roboto', sans-serif;
font-weight: 300;
text-shadow: $text-shadow-light;
}
h2 {
font-size: 5vh;
margin-top: 5vh;
}
p {
font-size: 3vh;
letter-spacing: 2px;
margin-top: 3vh;
text-shadow: none;
}
.btn-next {
bottom: 0;
padding-bottom: 5vh;
position: absolute;
text-align: center;
transition: all 0.3s;
a {
font-size: 5vw;
&:hover {
font-size: 5.5vw;
}
}
}
.center-text {
text-align: center;
}
.left-text {
text-align: left;
}
.no-margin {
margin: 0;
}
.right-text {
text-align: right;
}
.title {
padding-left: 4vw;
h3 {
font-size: 3vw;
text-shadow: $text-shadow;
}
}
#portfolio-page {
min-height: 100vh;
position: relative;
}
h4 {
font-size: 2vw;
}
.active-item {
box-shadow: $box-shadow-o;
-moz-box-shadow: $box-shadow-o;
-webkit-box-shadow: $box-shadow-o;
}
.btn-portfolio {
padding-top: 20vh;
text-align: center;
transition: all 0.3s;
a {
font-size: 5vw;
&:hover {
font-size: 5.5vw;
}
}
}
#featured-content {
background: rgba(0, 0, 0, 0.1);
height: 65vh;
margin-top: 2vh;
padding: 3vh 0;
}
#featured-img img {
box-shadow: $box-shadow-light;
-moz-box-shadow: $box-shadow-light;
-webkit-box-shadow: $box-shadow-light;
}
#primary-featured {
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
height: 45.5vh;
top: 10%;
}
#secondary-featured {
margin-top: 3vh;
}
HTML(inside a div.container):
<div id="portfolio-page">
<div class="row">
<div class="col-lg-4 col-lg-offset-4">
<h2 class="center-text">My Portfolio</h2>
<hr>
</div>
</div>
<div class="row">
<div class="col-lg-12" id="featured-content">
<div class="row no-margin">
<div class="col-lg-1 btn-portfolio" id="left-button">
<a><i class="glyphicon glyphicon-chevron-left"></i></a>
</div>
<div class="col-lg-8 col-lg-offset-1" id="primary-featured">
<div class="row">
<div class="col-lg-5" id="featured-img">
<img src="includes/img/headers.jpg" alt="A cluster of header images." class="img-responsive">
</div>
<div class="col-lg-6 col-lg-offset-1" class="center-text">
<h4 id="featured-title">Placeholder</h4>
<hr>
<p id="featured-description">Placeholder text.</p>
</div>
</div>
</div>
<div class="col-lg-1 col-lg-offset-1 btn-portfolio" id="right-button">
<a><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
<div class="col-lg-6 col-lg-offset-3" id="secondary-featured">
<div class="row">
<div class="col-lg-2" id="secondary-feature1">
<img src="includes/img/placeholder.jpg" alt="A placeholder image." class="img-responsive">
</div>
<div class="col-lg-2 col-lg-offset-3" id="secondary-feature2">
<img src="includes/img/placeholder.jpg" alt="A placeholder image." class="img-responsive">
</div>
<div class="col-lg-2 col-lg-offset-3" id="secondary-feature3">
<img src="includes/img/placeholder.jpg" alt="A placeholder image." class="img-responsive">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 btn-next">
<a>
<i class="glyphicon glyphicon-chevron-down"></i>
</a>
</div>
</div>
</div>
Edit: Your problem is with position: absolute on .btn-next.
For absolutely positioned elements
This property specifies the distance between the left margin edge of
the element and the left edge of its containing block.
You have margin-left: -15px, so it aligns to center with the margin-left: -15px.
How to fix:
Add this to .btn-next:
right: 0;
left: 0;
...or you can remove position: absolute from .btn-next.
Alternative option:
The "down arrow" at the bottom isn't centered, because it's in the row class and that class has margin-left: 15px and margin-right: 15px.
If you give it margin: 0px, it'll be fine.
Rename div class="row" to something else or give it another class like div class="row down".
Examples:
<div class="down">
<div class="col-lg-12 btn-next">
<a>
<i class="glyphicon glyphicon-chevron-down"></i>
</a>
</div>
</div>
or
<div class="row down">
<div class="col-lg-12 btn-next">
<a>
<i class="glyphicon glyphicon-chevron-down"></i>
</a>
</div>
</div>
CSS (only if using second option):
.row.down {
margin: 0px;
}
I need a div to be created this way shown in the image
CSS code as follows :
/* Styles go here */
.col-sm-3.widget_1_box {
padding: 0 5px;
}
.bg-success {
background-color: #dff0d8;
}
.tile-progress {
padding: 30px;
margin-bottom:1em;;
}
I have created a div here in plnkr
<div class="widget_1">
<div class="col-sm-3 widget_1_box">
<div class="tile-progress musers">
<div class="newheader">
<h4><i class="topicname">Manage Users</i> </h4>
<!-- <div class="progress"><div class="progress-bar inviewport animated visible slideInLeft" style="width: 40%;"></div></div>-->
<!--<span>40% increase</span>-->
</div>
</div>
https://plnkr.co/edit/kMis2AGzSdKfc1Bhis3e?p=preview
Need assistance.
Use a linear gradient
div {
background: linear-gradient(110deg, #1e5799 50%, #663399 50%);
height: 100px;
}
h1 {
text-align: center;
background: #1e5799;
color: white;
border-bottom: 1px solid rgba(20, 67, 120, 1)
}
<div>
<h1>HEADER</h1>
</div>