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;
}
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.
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>
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.
<ion-view title="Categories">
<ion-content ng-init="loadImages()">
<div id="catlist">
<div class="row" ng-repeat="image in images" ng-if="$index % 2 === 0">
<div class="col" ng-if="$index < images.length">
<a data-id="{{cats[$index].CategoryID}}" >
<span id="Content" class="col col-25 ">{{cats[$index].CategoryName}}</span>
<img ng-src="{{images[$index].src}}" width="100%" />
</a>
</div>
<div class="col" ng-if="$index + 1 < images.length">
<a data-id="{{cats[$index+1].CategoryID}}" >
<span id="Content" class="col col-25 ">{{cats[$index+1].CategoryName}}</span>
<img ng-src="{{images[$index + 1].src}}" width="100%" />
</a>
</div>
</div>
</div>
</ion-content>
</ion-view>
#Content {
background: rgba(0, 0, 0, 0.8) none repeat scroll 0 0;
color: #f4f2f3;
height: auto;
position: absolute;
text-align: center;
width: 310px;
text-decoration: none !important;
background-opacity: 0.1;
font-family: arial;
font-size: 15px;
font-weight: bold;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-o-transition: 0.5s;
-ms-transition: 0.5s;
}
I have create the 2*2 image grid and shows the image caption on top of the image. But image caption width doesn't fit to image width. I am using ionic framework. How can I adjust image caption width depends on image width?
From checking in your css for #Content (this should be changed to class instead of id, because it suppose to has only one element for one id per page. But I don't think this why problem occur)
In your #Content style can you please try to change from
width: 310px;
to
width: 100%;
If this not work, try to add
display: block;
Hope this help, and sorry for my English :)
I want to set a button which allow the user to reset the contact form, is there any method to do it?
here is my coding for text field
<div style="float:left;width:600px;"><!--textfield-->
<div style="float:left;">
<div style="float:left;width:90px;padding-top:5px">
NAME
</div>
<div style="float:left;padding-top:4px">
:
<input type="text" class="textfield"/>
</div>
</div>
<div style="float:left;padding-top:8px;">
<div style="float:left;width:90px;padding-top:5px">
EMAIL ADDRESS
</div>
<div style="float:left;padding-top:2px">
:
<input type="text" class="textfield"/>
</div>
</div>
<div style="float:left;padding-top:8px;">
<div style="float:left;width:90px;padding-top:5px">
CONTACT NUMBER
</div>
<div style="float:left;padding-top:2px">
:
<input type="text" class="textfield"/>
</div>
</div>
<div style="width:120p;float:left;padding-top:8px;">
<div style="float:left;width:90px;padding-top:5px">
MESSAGE
</div>
<div style="float:left;padding-top:2px">
:
</div>
<div style="float:left;margin-left:3px;padding-top:2px;">
<textarea cols="48" rows="6" class="textfield"></textarea>
</div>
</div>
</div><!--textfield-->
</div><!--end leave your personal details-->
<div style="clear:both"></div>
<div>
<div id="buttonreset"><!--buttonreset-->
<img src="img/buttonreset1.png" width="54" height="24" alt="reset" />
</div><!--end.buttonreset-->
<div id="buttonsend"><!--buttonsend-->
<img src="img/buttonsend1.png" width="54" height="24" alt="send" />
</div><!--end.buttonsend-->
</div>
Css
.textfield {
font-family: CenturyGothic;
font-size: 12px;
color: #231F20;
resize: none;
text-align: left;
}
textarea {
border: thin solid #221F1F;
border-radius: 5px;
width: 430px;
height: 160px;
opacity: 0.8;
}
input {
border: thin solid #221F1F;
border-radius: 4px;
width: 430px;
height: 21px;
opacity: 0.7;
}
#buttonreset {
margin-top: 5px;
background-image: url(../img/buttonreset.png);
background-repeat: no-repeat;
height: 24px;
width: 54px;
margin-top: 10px;
margin-left: 410px;
float:left;
}
#buttonreset img {
-webkit-transition: opacity .5s ease-in-out;
-moz-transition: opacity .5s ease-in-out;
-o-transition: opacity .5s ease-in-out;
transition: opacity .5s ease-in-out;
opacity:0;
}
#buttonreset img:hover {
opacity:1;
cursor:pointer;
-webkit-animation-duration: 1s;
-webkit-animation-timing-function: linear;
Chrome, and Safari */
}
I haven't add any coding to my button, what code suitable for my button?
this is my fiddle:
http://jsfiddle.net/K5CJ4/
<input type='reset'>
is the easiest method.
[Edit]
Since you're trying to reset the form using an image, the easiest way is to use the reset() method in Javascript. (No need for a library like jQuery). To accomplish this, I simply added a bit of javascript to your <a> tag in your form, as well as wrapped the entire example in <form></form> tags, giving it an id of contactForm .
DEMO
use jQuery way to solve it. like this :
$("#buttonreset").click(function() { // div's id
$("#txtField1").val("");
$("#txtField2").val("");
});
Try to use :
<button type="reset" id="btnreset" value="Reset">Reset</button>
The button is a reset button (resets the form-data to its initial values)
#btnreset {
background-image: url("http://www.ricksdailytips.com/wp-content/uploads/2013/11/reset-button.gif");
border: 0 none;
height: 204px;
width: 200px;
}
If you want to automate this, you could set it such that the page refreshes the entire page after a given number of seconds. use the meta tag:
<meta http-equiv="refresh" content="(enter number of seconds before refresh);url=thispage.html" />