On my website I have 3 bootstrap columns and each has a photo at the end. The problem is that the titles have different lengths and because of that when I resize the browser (at 1100px width) one of the pictures and the paragraph above it shift a little bit lower then the other 2. Is it possible to align the photos and pragraphs at the bottom and the title at the top?
Here is a JsFiddle of the problem I have
I don't now why but in JsFiddle the columns are all in one column and not multiple (like on a mobile device) but maybe if you save it and then open it in your browser you can see the problem.
HTML:
<div class="container-fluid">
<div class="row ">
<div class="col-md-4 column">
<center>
<h1>Babababababababababababababa</h1>
<p>2013 - Now</p>
<div>
<div class="container-images"> <img class="image" src="https://iso.500px.com/wp-content/uploads/2016/05/stock-photo-93725859-1500x1000.jpg">
<div class="over">
<p class="title">aaa</p>
<p class="rayal">aaaaaa</p>
</div>
</div>
</div>
</center>
</div>
<div class="col-md-4 column">
<center>
<h1>Bababababababababababababababababa</h1>
<p>2009 - 2013</p>
<div class="container-images"> <img class="image" src="https://iso.500px.com/wp-content/uploads/2016/05/stock-photo-93725859-1500x1000.jpg">
<div class="over">
<p class="title">aaa</p>
<p class="rayal">aaaaa</p>
</div>
</center>
</div>
<div class="col-md-4 column">
<center>
<h1>Babababababababababababababab</h1>
<p>2007 - 2009</p>
<div class="container-images"> <img class="image" src="https://iso.500px.com/wp-content/uploads/2016/05/stock-photo-93725859-1500x1000.jpg">
<div class="over">
<p class="title">aaa</p>
<p class="rayal">aaaaa</p>
</div>
</center>
</div>
</div>
</div>
CSS:
.container-images {
height: 300px;
width: 75%;
overflow: hidden;
display: flex;
/* align-items: center;*/
justify-content: center;
position: relative;
border-radius: 100px;
}
.image {
width: 100%;
height: 100%;
position: relative;
z-index: 1;
background-size: cover;
border-radius: 100px;
display: block;
float: left;
box-sizing: border-box;
-moz-box-sizing: border-box;
margin-bottom: 50px;
}
.over {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
z-index: 2;
background: rgba(0, 0, 0, 0.2);
transition: all 0.3s ease-in-out;
border-radius: 100px;
}
.title {
margin-top: 100px;
color: white;
transition: all 0.5s ease-in-out;
font-family: RobotoSlab-Regular;
opacity: 0;
}
.rayal {
opacity: 0;
color: white;
transition: all 0.5s ease-in-out;
font-family: RobotoSlab-Regular;
}
.over:hover {
background: rgba(0, 0, 0, 0.5);
}
.over:hover .title {
margin-top: 0;
opacity: 1;
}
.over:hover .rayal {
opacity: 1;
}
This is a good example for flexbox.
Here's an updated example of your plunker:
https://jsfiddle.net/eqcyyae9/9/
A few notes on this:
I removed your <center> tags. These are depreciated, and it's not a good practice to use them (as described here). The same effect can be achieved using the Bootstrap center-block CSS class.
I removed the flexbox properties on your container-images class. The centering you were doing in that case is handled by center-block, and as a personal preference I only use Flexbox when necessary so my CSS degrades as gracefully as possible for older browsers.
I added a container-content class which does have flexbox on it. Using the space-between attribute with the flex-direction: column allows your content to take up the designated space (570px in this example). Your header will always stick to the top, and your image will stick to the bottom and any extra space will end up in-between (thus, space-between). There's a really good article on this here if you have more interest in looking into it.
As a side note, plunker asks that you add all file dependencies to the "External Resources" section rather then directly to the HTML. That's why you weren't seeing your Bootstrap styles come through.
Related
I am trying to style the gif by giving it border-radius. However ther gif is smaller than the column itself so border-radius is aplied only to the right side of the gif. Could anyone help me out in applying it to the left side aswell? I dont want to change the background-size: contain!important; because then I will loose the proportions of the gif.
PS. Snippet breakes the row and the gif is in another row but it doesn't matter in this example.
.half-half-image-text {
padding: 70px 0px;
}
.half-half-image-text h1 {
color: #800000;
}
.half-half-image-text .content {
height: 100%;
display: flex;
align-items: center;
padding: 35px 0px;
}
.half-half-image-text .content p {
font-size: 22px;
}
.half-half-image-text .img {
min-height: 320px;
height: 100%;
border-radius: 10px;
}
<!-- begin snippet: js hide: false console: true babel: false -->
<div class="half-half-image-text">
<div class="container" >
<div class="row">
<div class="col-7 col-lg-7" style="padding-right:0">
<div class="content">
<p>At Fluid Automotive, our purpose is to make automotive parts easily accessible for everyone. Working with our partner brands, we aim to retail the highest quality parts, whilst maintaining a high level of customer satisfaction.</p>
</div>
</div>
<div class="col-5 col-lg-5" style="padding-right:0">
<a href="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/240px-Rotating_earth_%28large%29.gif" data-gallery="portfolioGallery" class="portfolio-lightbox">
<div class="img customzoom s2" style="background-size: contain!important;box-shadow: none;
background: url('https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/240px-Rotating_earth_%28large%29.gif')no-repeat center right;background-size:cover;" alt="Plan rozwoju" title="Plan rozwoju"></div>
</a>
</div>
</div>
</div>
</div>
You could add this style to portfolio-lightbox :
width: 240px;
display: block;
and change min-height:320px; to min-height:240px will solve your problem. Like below :
half-half-image-text {
padding: 70px 0px;
}
.half-half-image-text h1 {
color: #800000;
}
.half-half-image-text .content {
height: 100%;
display: flex;
align-items: center;
padding: 35px 0px;
}
.half-half-image-text .content p {
font-size: 22px;
}
.half-half-image-text .img {
min-height: 240px;
height: 100%;
border-radius: 10px;
}
.portfolio-lightbox {
width: 240px;
display: block;
}
<div class="half-half-image-text">
<div class="container" >
<div class="row">
<div class="col-7 col-lg-7" style="padding-right:0">
<div class="content">
<p>At Fluid Automotive, our purpose is to make automotive parts easily accessible for everyone. Working with our partner brands, we aim to retail the highest quality parts, whilst maintaining a high level of customer satisfaction.</p>
</div>
</div>
<div class="col-5 col-lg-5" style="padding-right:0">
<a href="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/240px-Rotating_earth_%28large%29.gif" data-gallery="portfolioGallery" class="portfolio-lightbox">
<div class="img customzoom s2" style="background-size: contain!important;box-shadow: none;
background: url('https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/240px-Rotating_earth_%28large%29.gif')no-repeat center right;background-size:cover;" alt="Plan rozwoju" title="Plan rozwoju"></div>
</a>
</div>
</div>
</div>
</div>
Simply use an image tag.
.imgradius {
border-radius: 10px
}
<img class="imgradius" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/240px-Rotating_earth_%28large%29.gif"></img>
I'm using Vis.js to create diagrams. Relevant code:
.defaultSection {
border: 1px solid #bbbbbb;
padding-bottom: 0px;
margin: 5px;
width: calc(100% - 10px);
}
.overflowHidden {
overflow: hidden;
overflow-x: hidden;
overflow-y: hidden;
}
.flexParent {
display: flex;
justify-content: space-between;
padding: 2px;
}
.flexParentInvisible {
display: flex;
justify-content: space-between;
}
.flexElement {
flex-basis: 100%;
}
.flexPanel {
flex-basis: 100%;
}
.roundedCorners {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
transition: 0.3s;
border-radius: 5px;
margin: 5px;
}
<div data-panes="true">
<div id="Tab-ta6f7ijb-Content" class="active">
<div class="defaultSection roundedCorners overflowHidden">
<div class="defaultHeader" style="text-align:center;background-color:#00bfff"><a name="Test" style="color: #ffffff;">Test </a><a id="show_505656775" href="javascript:void(0)" onclick="show('505656775');" style="color: #ffffff; display:none;">(Show)</a><a id="hide_505656775" href="javascript:void(0)" onclick="hide('505656775');"
style="color: #ffffff; display:none;">(Hide)</a></div>
<div id="505656775" class="flexParent flexElement overflowHidden">
<div id="505656775" class="flexParent flexElement overflowHidden collapsable">
<div id="Diagram-hvardq4p" class="diagram"></div>
</div>
</div>
</div>
</div>
</div>
Full code: https://codepen.io/MadBoyEvo/pen/XWmbZra
It works fine in Chrome, Edge, IE and even Firefox with one problem. In firefox, the section where diagram is located keeps on resizing itself over and over. I'm sure this is my mistake with CSS but whatever I try to fix it doesn't work.
The diagram is contained in a <canvas> element. That element has two height values assigned, both as inline styles:
height: 100%, and
height="484" (or whatever value it happens to have at the moment).
Once you remove the height: 100% the rolling expansion stops.
Author of Vis.js provided me with a tip: https://github.com/visjs/vis-network/issues/628
<div Class="diagram" Style="position:relative">
<div style="position:absolute" id="Diagram-w5gcskfb" class="diagram"></div>
</div>
This solves it for me.
My CSS:
#container {
position: center;
margin-top: 80px;
z-index: 950;
{block:IfGridTheme}margin-left: 430px;{/block:IfGridTheme}
{block:IfNotGridTheme}margin-left: 435px;{/block:IfNotGridTheme}
}
.entry {
position: justify;
font-size: 12px;
color: {color:Body Text};
font-family: roboto condensed;
letter-spacing: 1px;
{block:PermalinkPage}width: 1000px;
margin-top: 15px;{/block:PermalinkPage}
word-wrap: break-word;
margin-top: 45px;
}
#container1 {
white-space: nowrap;
border: none;
width: 100%;
margin-left: auto;
margin-right: auto;
}
#container1 > div {
background: none;
width: 100%;
height: 100%;
display: inline-block;
padding: 1% 5%;
margin-right: 176px;
}
.stretch {
width: 100%;
display: inline-block;
font-size: 0;
line-height: 0
}
and my HTML for a certain type of page:
<div id="container1">
<div>
<div class="picture_holder" style="width: 1080px;">
<div class="picture" style="width: 1080px;"><img alt="LINKTOFIRSTIMAGE" height="575" src="LINKTOFIRSTIMAGE" />
<div class="captioning">
<div class="caption"><em>CAPTION</em></div>
</div>
</div>
</div>
</div>
<div>
<div class="picture_holder" style="width: 1080px;">
<div class="picture" style="width: 1080px;"><img alt="SECONDIMAGELINKANDSOFORTH" height="575" src="SECONDIMAGELINKANDSOFORTH" />
<div class="captioning">
<div class="caption"></div>
</div>
</div>
</div>
</div>
</div>
On a given page with a sequence of images that are exactly the same height, width, and overall aspect ratio, the spacing between them is exactly the same (though a lot wider than I would like) like in 1) of this drawing:
... but in a sequence of images that have the same height but wildly varying widths, the spacing is pretty off like in 2).
I personally don't want either. How do I change my code so that, for both these types of pages and however many more pages I plan to create, that the spacing between every image is exactly the same amount of pixels across the whole board of the site? Is there an imaginary box around these images causing the issue?
edit: I should also state that I am using the HTML function on a website, Tumblr.com, so certain properties like flex never seem available.
edit2: display: grid; and similar don't appear available either. This is also at the top of the code if that helps:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Thank you for the info so far.
Your html structure:
<div id="parent_container">
<div id="card_1" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:red">
<caption>Card 1 caption</caption>
</div>
<div id="card_2" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:violet">
<caption>Card 2 caption</caption>
</div>
<div id="card_3" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:seagreen">
<caption>Card 3 caption</caption>
</div>
<div id="card_4" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:skyblue">
<caption>Card 4 caption</caption>
</div>
</div>
Your CSS structure:
#parent_container <=== setting up flex for container
{
display: flex;
flex-wrap: wrap; <=== makes sure if the cards are many then they go on next line
justify-content: space-evenly; <=== makes sure there is equal space
}
.card_properties
{
border: 1px solid rgba(0,0,0,0.2);
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
border-radius: 14px;
width:20vw;
height:200px;
padding:1em;
}
img <=== written this additional because I didn't have time to find image
{
width: 100%;
height: 120px;
border-radius: 14px
}
Working codepen example
I've got the following landing page form (I've cut all the unnecessary stuff I don't think matters leaving only minimum of style). Here is the code (I'm using Bootstrap 3.3.5):
<div class="col-md-6 app-door">
<form class="image-hover text-center">
<h3>Application name</h3>
<div class="landing-page-form-group">
<label class="landing-page-label">Label: </label>
<input class="form-control landing-page-input">
</div>
<button class="btn">Submit</button>
</form>
<div class="center-block app-link some-img"/>
</div>
..and css
.image-hover {
width: 300px;
height: 300px;
background-color: rgba(0, 0, 0, 0.7) !important;
position: absolute;
z-index: 100;
color: #cccccc;
margin: 0 auto;
left: 0;
right: 0;
border-radius: 25px;
}
.landing-page-form-group {
padding-top: 16px;
padding-bottom: 16px;
}
.landing-page-label {
width: 100px;
vertical-align: middle;
}
.landing-page-input {
width: 150px;
display: inline-block;
}
.app-link {
width: 300px;
height: 300px;
background-size: 100% 100%;
border-radius: 25px;
}
.some-img {
background-image: url("http://dl.hiapphere.com/data/icon/201511/HiAppHere_com_com.ludicside.mrsquare.png");
}
I want to center all the form inputs and etc vertically. I've tried such things as playing with position (relative on parent, absolute on child), vertical-align, top, maybe something else I don't remember right now as I spent lots of hours trying.
I'm not a great specialist in frontend development (I mean html/css) so I will be extremely happy to see understanding although the problem seems to be basic enough.
Thank you for any ideas!
updated
check the solution without flex demo here
Try this
check demo here
add the following styles to your existing .image-hover class
CSS:
.image-hover {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
}
Simplest method would be to use
.image-hover {
display: flex;
align-items : center;
justify-content: center;
}
The align-items takes care of vertical centering, and justify-contents, the horizontal centering.
This is my solution:
https://jsfiddle.net/0x9epxah/1/
add div .inner-form:
<div class="col-md-6 app-door">
<form class="image-hover text-center">
<div class="inner-form">
<h3>Application name</h3>
<div class="landing-page-form-group">
<label class="landing-page-label">Label: </label>
<input class="form-control landing-page-input">
</div>
<button class="btn">Submit</button>
</div>
</form>
<div class="center-block app-link some-img"/>
</div>
and this css class:
.inner-form {
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%,-50%);
}
What I would like to achieve (the goal)...
I'm trying to display a row of images (with the image name below the image) in html, like so:
When a user clicks on an image I want a square to appear over the image, to indicated selection like so (user has clicked on Tile1):
What I have done so far...
So far I have managed to display the tiles in a row:
Here's the html code that produced the image above:
<div id='default_tiles_view'>
<div class="default_tiles_view_square" id="tile1">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/tile.png">
<p>Tile1</p>
</div>
<div class="default_tiles_view_square" id="tile2">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/dirt.png">
<p>Tile2</p>
</div>
</div>
And the CSS:
#default_tiles_view {
width: 490px;
height: 160px;
overflow-y: auto;
}
.default_tiles_view_square {
display: inline-block;
}
.default_tiles_view_square p {
text-align: center;
}
And a fiddle showing the example above: http://jsfiddle.net/jamiefearon/t8d6U/
The strategy to achieve the goal...
I was thinking about wrapping the image and its title in a div, and then changing the background colour of the div. Here is the result and the code:
HTML:
<div id='default_tiles_view'>
<div class="tile_wrap" id="tile1">
<div class="default_tiles_view_square">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/tile.png">
<p>Tile1</p>
</div>
</div>
<div class="tile_wrap" id="tile2">
<div class="default_tiles_view_square">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/dirt.png">
<p>Tile2</p>
</div>
</div>
</div>
CSS:
#default_tiles_view {
width: 490px;
height: 160px;
overflow-y: auto;
}
.tile_wrap {
display: inline-block;
}
.default_tiles_view_square p {
text-align: center;
}
#tile1 {
background-color:red;
}
The Problem..
It does not look good, and the actual image is not covered by the red colour. Maybe it would be possible to overlay a div over the wrap div, set it's opacity < 1 and change its background colour.
What do think? Does anyone have any ideas of a good way to achieve the goal?
Something like this should do the trick: http://jsfiddle.net/t8d6U/1/
So just hide the overlay DIVs initially with display:none (or e.g. left:-9999px) then show them onClick.
CSS:
#default_tiles_view {
overflow: auto;
}
.default_tiles_view_square {
float: left;
margin: 5px 10px 10px 10px;
position: relative;
height: 128px;
width: 128px;
}
.default_tiles_view_square p {
text-align: center;
}
.content {
position: absolute;
z-index: 1;
top: 0;
left: 0;
}
.overlay {
position: absolute;
z-index: 2;
background: red;
opacity: 0.5;
height: 128px;
width: 128px;
top: 0;
left: 0;
}
HTML:
<div id='default_tiles_view'>
<div class="default_tiles_view_square" id="tile1">
<div class="content">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/tile.png">
<p>Tile1</p>
</div>
<div class="overlay"></div>
</div>
<div class="default_tiles_view_square" id="tile2">
<div class="content">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/dirt.png">
<p>Tile2</p>
</div>
<div class="overlay"></div>
</div>
</div>
I have taken what Gaurav said in the comments, changing the opacity:
HTML
<div id='default_tiles_view'>
<div class="tile_wrap" id="tile1">
<div class="default_tiles_view_square">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/tile.png">
<p>Tile1</p>
</div>
</div>
<div class="tile_wrap" id="tile2">
<div class="default_tiles_view_square">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/dirt.png">
<p>Tile2</p>
</div>
</div>
</div>
CSS
#default_tiles_view {
width: 490px;
height: 160px;
overflow-y: auto;
}
#tile1:hover{
background:red;
opacity:0.4;
}
.tile_wrap {
display: inline-block;
}
.default_tiles_view_square p {
text-align: center;
}
Fiddle: http://jsfiddle.net/jamiefearon/BY9Fp/
Hover over Tile1 to see the effect.