This question already has answers here:
Add a CSS border on hover without moving the element [duplicate]
(4 answers)
Closed 1 year ago.
When I hover on the total-contents so the picture moves from its real place and the whole content in the div moves a bit and leaves its position
.total-contents:hover .content-products {
border: 2px solid #BC463A;
}
.total-contents:hover .content-products-text {
background-color: #BC463A;
transition: all .4s ease-in-out 0s;
}
.total-contents:hover .content-products-text a {
color: #ffffff;
text-decoration: none;
}
<div class="col-md-4 total-contents">
<div class="row">
<div class="col-12 content-products m-auto">
<img class="img-fluid d-inline mx-auto product-img-height" src="{{asset('images/products/14.jpg')}}" width="80%">
</div>
<div class="col-12 text-center p-3 content-products-text">
<p class="text-capitalize m-auto">Partial Covered Rigid Boxes</p>
</div>
</div>
</div>
you need to account for the 2px border you are adding, you could add a transparent border whilst not hovering.
.total-contents .content-products {
border: 2px solid transparent;
}
.total-contents:hover .content-products {
border: 2px solid #BC463A;
}
.total-contents:hover .content-products-text {
background-color: #BC463A;
transition: all .4s ease-in-out 0s;
}
.total-contents:hover .content-products-text a {
color: #ffffff;
text-decoration: none;
}
<div class="col-md-4 total-contents">
<div class="row">
<div class="col-12 content-products m-auto">
<img class="img-fluid d-inline mx-auto product-img-height" src="{{asset('images/products/14.jpg')}}" width="80%">
</div>
<div class="col-12 text-center p-3 content-products-text">
<p class="text-capitalize m-auto">Partial Covered Rigid Boxes</p>
</div>
</div>
</div>
Related
I want both of these css styles to apply to the jumbotron text object, but only one or the other does and I cannot think of a way to combine them since they have competing properties. The little image file (jumbotron_ribbon.png and jumbotron_ribbon_left.png) creates a little "flag" at the end of the button that says "The Washington Post" on it. I want the little flag on the left AND the right, not just one or the other.
.jumbotron_text .btn:before {
content: '';
position: absolute;
right: -11px;
top: 5px;
width: 9px;
height: 25px;
background-image: url(../images/jumbotron_ribbon.png);
background-repeat: no-repeat;
background-position: top right;
background-color: #505050;
transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
}
.jumbotron_text .btn:before {
content: '';
position: absolute;
left: -11px;
top: 5px;
width: 9px;
height: 25px;
background-image: url(../images/jumbotron_ribbon_left.png);
background-repeat: no-repeat;
background-position: top right;
background-color: #505050;
transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- Jumbotron -->
<section class="full_width jumbotron">
<div class="row jumbotron_text" data-animated="fadeIn">
<div class="col-lg-4 col-md-4 margbot30 clearfix">
<div class="content">
<span>alpha beta</span>
<a class="btn btn-default btn-sm" href="javascript:void(0);" alt="">The Washington Post</a>
</div>
</div>
<div class="col-lg-4 col-md-4 margbot30 clearfix">
<div class="content">
<span>gamma delta</span>
<a class="btn btn-default btn-sm" href="javascript:void(0);" alt="">The Washington Post</a>
</div>
</div>
<div class="col-lg-4 col-md-4 margbot30 clearfix">
<div class="content">
<span>epsilon alpha</span>
<a class="btn btn-default btn-sm" href="javascript:void(0);" alt="">The Washington Post</a>
</div>
</div>
</div>
</section>
<!-- //Jumbotron -->
It is completely useless to use the exact same selector ( .jumbotron_text .btn:before ) more than one time.
The element it target will just have the background-image that is lower in your css. The same goes for any other identical properties. And if the properties aren't identical, you should just regroup them under one css selector.
If you want to target something else, you want to use another selector.
Maybe you can try your luck with the :after selector.
I'm adjusting the html / css on a hugo theme, but can't find resources on setting text boxes to a uniform height. Image shows current boxes, with height varying according to amount of text.
The text boxes look like:
The theme partial /layouts/partials/service.html looks like this:
{{"<!-- /section title -->" | safeHTML }}
{{ range .Site.Data.service.serviceItem}}
{{"<!-- Single Service Item -->" | safeHTML }}
<article class="col-lg-3 col-md-3 col-12 wow fadeInUp" data-wow-duration="500ms">
<div class="service-block text-center">
<div class="service-icon text-center">
<i class="{{ .icon }}"></i>
</div>
<h3>{{ .title }}</h3>
<p>{{ .content }}</p>
</div>
</article>
{{"<!-- End Single Service Item -->" | safeHTML }}
{{ end }}
and the CSS for the section looks like:
.service-2 .service-item {
border: 1px solid #eee;
margin-bottom: 30px;
padding: 50px 20px;
transition: all 0.3s ease 0s;
}
.service-2 .service-item:hover {
box-shadow: 0 5px 65px 0 rgba(0, 0, 0, 0.15);
-webkit-box-shadow: 0 5px 65px 0 rgba(0, 0, 0, 0.15);
}
.service-2 .service-item:hover i {
background: #fff;
color: #57cbcc;
}
.service-2 .service-item i {
font-size: 30px;
display: inline-block;
background: #57cbcc none repeat scroll 0 0;
border-radius: 30px;
box-shadow: 0 5px 6px 0 rgba(0, 0, 0, 0.1);
color: #fff;
height: 200px;
line-height: 55px;
margin-bottom: 20px;
width: 55px;
transition: all 0.3s ease 0s;
}
Is there a way to set a fixed height on those text boxes?
You don't need js for this job. Add display: flex to the container of the blocks will do. The shorter children of the container will "grow up" to fit into the container.
.flexcontainer{
display: flex;
}
.flexchild{
border: solid;
word-wrap: break-word;
width: 100px;
}
<div class="flexcontainer">
<div class="flexchild">
<h3>title </h3>
<p>asdf</p>
</div>
<div class="flexchild">
<h3>title </h3>
<p>asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf</p>
</div>
<div class="flexchild">
<h3>title </h3>
<p>asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf</p>
<p>asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf</p>
</div>
</div>
codepen
I find this flexbox guide to be useful
function getHeight(el) {
var styles = window.getComputedStyle(el);
var height = el.offsetHeight;
var borderTopWidth = parseFloat(styles.borderTopWidth);
var borderBottomWidth = parseFloat(styles.borderBottomWidth);
var paddingTop = parseFloat(styles.paddingTop);
var paddingBottom = parseFloat(styles.paddingBottom);
return height - borderBottomWidth - borderTopWidth - paddingTop - paddingBottom;
}
var heightList = [];
document.querySelectorAll('.service-block').forEach(function(el) {
heightList.push(getHeight(el))
})
var maxHeight = Math.max.apply(Math, heightList);
document.querySelectorAll('.service-block').forEach(function(el) {
el.style.height = maxHeight + "px";
})
.service-block {
width: 100px;
background-color: #eee;
padding: 10px;
}
.service-block p {
word-break: break-all;
}
.col-md-3 {
width: 33%;
float: left;
}
<body>
<div class="row">
<div class="col-md-3">
<div class="service-block text-center">
<div class="service-icon text-center">
<i class="fa fa-star"></i>
</div>
<h3>title</h3>
<p>content</p>
</div>
</div>
<div class="col-md-3">
<div class="service-block text-center">
<div class="service-icon text-center">
<i class="fa fa-star"></i>
</div>
<h3>title</h3>
<p>content.content.content.content.content.content</p>
</div>
</div>
<div class="col-md-3">
<div class="service-block text-center">
<div class="service-icon text-center">
<i class="fa fa-star"></i>
</div>
<h3>title</h3>
<p>content.content.content.content.content.contentcontent.content.content.content.content.contentcontent.content.content.content.content.contentcontent.content.content.content.content.contentcontent.content.content.content.content.contentcontent.content.content.content.content.contentcontent.content.content.content.content.content</p>
</div>
</div>
</div>
</body>
This is my way, get the maximum height and set it to each container.
Hez guys, I have some elements on page, which I've wrapped with border. The elements are close to each other so of course, on the place, where they touch each other, I've got double border.
Think is, I've made links from these elements, so now, some additional border is applyed and I don't know how to remove it.
Code below usefully removed double border when element's we're not links.
Can you please help me to remove this border which comes from link ?
Thank you}
HTML
<section class="popular-items clearfix">
<a href="detail.html">
<div class="item">
<img src="img/pink.png" alt="pink"><br>
<span>2015</span>
<h4 class="pink">pink</h4>
<p class="out-of-stock">Abc</p>
</div>
</a>
<a href="detail.html">
<div class="item">
<img src="img/white.png" alt="white"><br>
<h4 class="green">white</h4>
<p>5 €</p>
</div>
</a>
<a href="detail.html">
<div class="item">
<img src="img/pink.png" alt="pink"><br>
<h4 class="pink">Pink</h4>
<p class="coming-soon">Pink</p>
</div>
</a>
<a href="detail.html">
<div class="item">
<img src="img/red.png" alt="red"><br>
<h4 class="red">Red</h4>
<p>5 €</p>
</div>
</a>
</section>
SCSS
.popular-items {
width: 100%;
.item {
float: left;
width: 25%;
border: 1px solid #dddddd;
padding: 1%;
border-right-width: 0;
height: 420px;
&:last-child {
border-right-width: 1px;
}
&:hover + & {
border-left-width: 0;
}
&:hover {
border: 1px $dark solid;
}
}
}
Well i think you can fix that by setting the border of the links to 0px.
border : none;
I have a button created in a bootstrap project but I can't change the text color when I click the button. In visited state, when the pointer is not in the button, the text changes to blue and I want to stay in white. I think the problem is with the bootstrap css file but I don´t know how to solve that problem
here's the fiddle:
https://jsfiddle.net/pfrutuoso/Ljr8t8pz/
My html:
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<div class="form-group">
<label>CPF</label>
<input type="text" class="form-control">
<!-- <label class="form-error">Mensagem erro campo</label> -->
</div>
</div>
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
<div class="form-group">
<button class="btn btn-validarForm" type="button">Validar CPF</button>
</div>
</div>
</div>
and css:
.btn-validarForm{
font-family: 'Aleo Bold';
background-color: #8C0000;
color: #fff;
text-transform: uppercase;
text-shadow: 1px 1px 1px rgba(0,0,0,0.2);
border-radius: 2px;
border-top: 1px solid #D90000;
border-bottom: 1px solid #8C0000;
width:100%;
font-size:14px;
height:40px;
margin-top:23px;
border:none;
}
.btn-validarForm:hover,
.btn-validarForm:active,
.btn-validarForm:visited{
background-color: #B20000;
color: #fff;
}
Bootstrap also defines :focus state styles, override this in your CSS:
.btn-validarForm:hover,
.btn-validarForm:active,
.btn-validarForm:visited,
.btn-validarForm:focus{
background-color: #B20000;
color: #fff;
}
JSFiddle
Side-note: Most browsers come with the functionality within developer tools to trace the CSS styles for yourself. Chrome (not sure about other browsers) even let's you toggle the pseudo states and view the styles that will be applied for each state:
I'm making a simple product portfolio and using Bootstrap 3. Without captions my images look like this:
When I add captions under them they look like this:
I want them to stay like in picture one but with added captions below them.
Here is the HTML(with captions):
<div class="works-list type-one">
<div class="row">
#foreach($proizvodi as $proizvod)
<div class="col-md-3 col-sm-6">
<div class="work-item">
<div class="wi-over">
<h4>{{ $proizvod->naziv }}</h4>
<ul class="clearfix">
<li><img class="img-responsive"></img></li>
<li><i class="fa fa-file-text-o"></i></li>
</ul>
</div>
<img src="{{ $proizvod->slika_url }}" alt="Work Name" class="img-full-border">
</div>
<div class="row">
<div style="padding-top: 5px;">
<h5 style="font-weight:bold; font-size: 12px; text-align:center;">{{ mb_strtoupper($proizvod->naziv) }}</h5>
</div>
</div>
</div>
#endforeach
</div>
<div class="row">
<div style="text-align:center;">
{!! $proizvodi->render() !!}
</div>
</div>
</div>
I'm using Laravel so blade code is included.
Here are the related css classes:
.works-list.type-one{
margin-bottom : -30px;
}
.works-list.type-one .row div[class*="col-"]{
margin-bottom : 30px;
}
.works-list.type-one .work-item{
position : relative;
}
This problem only occurs when the caption is longer than 1 line.
Any ideas?
.thumbnail {
display: block;
padding: 4px;
margin-bottom: 20px;
line-height: 1.42857143;
background-color: #fff;
border: 0px solid #ddd;
border-radius: 4px;
-webkit-transition: border .2s ease-in-out;
-o-transition: border .2s ease-in-out;
transition: border .2s ease-in-out;
}
.row {
margin-right: 0px;
margin-left: 0px;
}