This works for bigger screen and shows the way I want but on Mobile, "Right Title" overlaps the "Left Title". Left title should go up but Right Title should be below it but instead, it goes on top of the Left Title.
What should I do?
<div class="IdeathonCover">
<img class="img-responsive" width="100%" src="bg-image.jpg">
<div class="IdeathonLeftTitle">
<h1>Left Title</h1>
</div>
<div class="IdeathonRightTitle">
<h1>Right Title</h1>
</div>
</div>
I tried this method too using the bootstrap 3 layout but it didn't work. The "col-x-12" is not being respected:
<div class="IdeathonCover">
<img class="img-responsive" width="100%" src="bgimage.jpg">
<div class="row">
<div class="col-md-6 col-xs-12">
<div class="IdeathonLeftTitle">
<h1>Left Title</h1>
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="IdeathonRightTitle">
<h1>Right Title</h1>
</div>
</div>
</div>
</div>
The CSS used is below:
.IdeathonCover {
position: relative;
}
.IdeathonLeftTitle {
position:absolute;
bottom: 10%;
left: 0;
padding: 0px 50px 20px;
color: #fff;
font-weight: 300;
}
.IdeathonRightTitle {
position:absolute;
bottom: 10%;
right: 0;
padding: 0px 50px 20px;
color: #fff;
font-weight: 300;
}
Anyone knows why this is happening?!
If you are using Bootstrap, as far as I'm aware, there is nothing wrong with using Bootstrap classes within absolute positioned elements. You could try something along the lines of:
CSS:
.IdeathonCover {
position: relative;
}
.IdeathonTitles {
position: absolute;
bottom: 10%;
width: 100%;
}
And your html:
<div class="container-fluid">
<div class="row">
<div class="IdeathonCover">
<img class="img-responsive" src="bgimage.jpg" alt="">
<div class="IdeathonTitles">
<div class="col-md-6">
<h1 class="text-center">Left title</h1>
</div>
<div class="col-md-6">
<h1 class="text-center">Right title</h1>
</div>
</div>
</div>
</div>
</div>
try adding this in the end of your css file-
#media (min-width: 320px) and (max-width: 750px){
.IdeathonLeftTitle { right: 0; }
.IdeathonRightTitle { left: 0; top: 67px; }
}
it should help.
Related
i have set up a gallery on my website which displays a large embedded video with 3 thumbnail embedded videos underneath which looks great on the desktop but as i switch to the phone view the 3 thumbnail videos stay in line and dont drop underneath each other as i imagined. Meaning you have to scroll away from the phone screen to view. could someone please advise as to what i need to do? below is the html and css code.
.vid-container {
position: relative;
padding-bottom: 52%;
padding-top: 30px;
height: 0;
}
.vid-container iframe,
.vid-container object,
.vid-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.vid-list-container {
width: 92%;
overflow: hidden;
margin-top: 20px;
margin-left:4%;
padding-bottom: 20px;
}
.vid-list {
width: 1344px;
position: relative;
top:0;
left: 0;
}
.vid-item {
display: block;
position: relative;
width: 18%;
height: 18%;
float: left;
margin: 0;
padding: 10px;
}
.thumb {
overflow:hidden;
height: 84%;
}
.thumb img {
width: 100%;
position: relative;
top: -13px;
}
.vid-item .desc {
color: #21A1D2;
font-size: 15px;
margin-top:5px;
}
<div class="container">
<div class="row">
<div class="m-3 col-xs-7 col-sm-6 col-lg-8">
<h3>This week we are watching....</h3>
<div class="embed-responsive embed-responsive-16by9">
<iframe id="vid_frame" src="https://www.youtube.com/embed/RfuNhK_o9no" frameborder="0"></iframe>
</div>
<div class ="vid-list">
<div class="vid-item" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/HBmDFJRwzQ8'">
<div class="thumb">
<img src="http://img.youtube.com/vi/HBmDFJRwzQ8/0.jpg" alt="" />
</div>
<div class="desc">
Living a healthy lifestyle doesn’t always come easy! But with this one pot meal it doesnt get much easier
</div>
</div>
<div class="vid-item" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/U0jggZfufGU'">
<div class="thumb">
<img src="http://img.youtube.com/vi/U0jggZfufGU/0.jpg" alt="" />
</div>
<div class="desc">
Hey everyone welcome back! Today I have some easy and delicious summer treats! These are easy and inexpensive treats and taste amazing! I hope you enjoyed!
</div>
</div>
<div class="vid-item" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/p4b2rFW8cms'">
<div class="thumb">
<img src="http://img.youtube.com/vi/p4b2rFW8cms/0.jpg" alt="" />
</div>
<div class="desc">
From the archives: Once again Gennaro invites us into his home to show us another wholesome home cooked meal.
</div>
</div>
</div>
</div>
</div>
</div>
make sure that if you added view port meta <meta name="viewport" content="user-scalable=yes, initial-scale=1, maximum-scale=2, minimum-scale=0.5, width=device-width, height=device-height, target-densitydpi=device-dpi" />
like above, also your media query does not respond without viewport for responsive
Guess you want to achieve this?
If you are already using bootstrap why not use another nested row for the videos below the 'main'-video?
I replaced the .vid-list class with a .row bootstrap class and assumed that you want to have three other videos below the main video. Since bootstrap is using 12 columns i divided 12 by 3 and got 4. So i used .col-md-4 to use 4 columns for one video. On small devices you want to use the full length so you are using .col-sm-12.
And try to avoid using negative top and margin values. I also cleared up some (not everything) of unnecessary code.
.vid-container {
position: relative;
padding-bottom: 52%;
padding-top: 30px;
height: 0;
}
.vid-container iframe,
.vid-container object,
.vid-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.vid-list-container {
width: 92%;
overflow: hidden;
margin-top: 20px;
margin-left:4%;
padding-bottom: 20px;
}
.vid-list {
margin-top: 10px;
}
.thumb {
overflow:hidden;
height: 84%;
}
.thumb img {
width: 100%;
position: relative;
top: -13px;
}
.vid-item .desc {
color: #21A1D2;
font-size: 15px;
margin-top:5px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="m-3 col-xs-7 col-sm-6 col-lg-8">
<h3>This week we are watching....</h3>
<div class="embed-responsive embed-responsive-16by9">
<iframe id="vid_frame" src="https://www.youtube.com/embed/RfuNhK_o9no" frameborder="0"></iframe>
</div>
<div class ="row vid-list">
<div class="vid-item col-sm-12 col-md-4" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/HBmDFJRwzQ8'">
<div class="thumb">
<img src="http://img.youtube.com/vi/HBmDFJRwzQ8/0.jpg" alt="" />
</div>
<div class="desc">
Living a healthy lifestyle doesn’t always come easy! But with this one pot meal it doesnt get much easier
</div>
</div>
<div class="vid-item col-sm-12 col-md-4" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/U0jggZfufGU'">
<div class="thumb">
<img src="http://img.youtube.com/vi/U0jggZfufGU/0.jpg" alt="" />
</div>
<div class="desc">
Hey everyone welcome back! Today I have some easy and delicious summer treats! These are easy and inexpensive treats and taste amazing! I hope you enjoyed!
</div>
</div>
<div class="vid-item col-sm-12 col-md-4" onClick="document.getElementById('vid_frame').src='https://www.youtube.com/embed/p4b2rFW8cms'">
<div class="thumb">
<img src="http://img.youtube.com/vi/p4b2rFW8cms/0.jpg" alt="" />
</div>
<div class="desc">
From the archives: Once again Gennaro invites us into his home to show us another wholesome home cooked meal.
</div>
</div>
</div>
</div>
</div>
</div>
How can I center 2 pictures, one after another? Every picture has a description that stands at the right of the picture.
CSS
.message-icon_description {
text-align: left;
font-size: 15px;
color: #606060;
opacity: 1;
}
.left-logo img {
float: left;
margin: 15px 15px 15px 0px;
}
HTML
<div class="message-icons">
<div class="left-logo">
<img src="./images/blue.png" alt="blue-message-logo">
<div class="message-icon_description">
<p>Description1</p>
</div>
</div>
</div>
<div class="message-icons">
<div class="left-logo">
<img src="./images/yellow.png" alt="yellow-message-logo">
<div class="message-icon_description">
<p>Description2</p>
</div>
</div>
</div>
This is what I've tried by now, but it's not working well, it shows me picture1_description1 picture2_description2 as I want, but they are not centred, they begin from the left. Any suggestions?
Is this what you are trying to achieve?
.message-icon_description {
text-align: left;
font-size: 15px;
color: #606060;
opacity: 1;
}
.left-logo {
display:flex;
}
.left-logo img {
//float: left;
margin: 15px 15px 15px 0px;
}
.container {
display:flex;
}
<div class="container">
<div class="message-icons">
<div class="left-logo">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTwy9x2ChZ-mbHy-lx9ZPRe5ZhIk3SLHCMBVzMaiTlg_3bSIOAn6fC3Wjk" alt="blue-message-logo">
<div class="message-icon_description">
<p>Description1</p>
</div>
</div>
</div>
<div class="message-icons">
<div class="left-logo">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTwy9x2ChZ-mbHy-lx9ZPRe5ZhIk3SLHCMBVzMaiTlg_3bSIOAn6fC3Wjk" alt="yellow-message-logo">
<div class="message-icon_description">
<p>Description2</p>
</div>
</div>
</div>
</div>
It sounds to me as though you're looking to display the images next to each other, centralised, with their descriptions underneath. To achieve this, you're looking to create a container for the messages which has text-align: center, in addition to making .message-icons display as inline-block:
.message-container {
text-align: center;
}
.message-icons {
display: inline-block;
}
<div class="message-container">
<div class="message-icons">
<div class="left-logo">
<img src="http://via.placeholder.com/100" alt="blue-message-logo">
<div class="message-icon_description">
<p>Description1</p>
</div>
</div>
</div>
<div class="message-icons">
<div class="left-logo">
<img src="http://via.placeholder.com/100" alt="yellow-message-logo">
<div class="message-icon_description">
<p>Description2</p>
</div>
</div>
</div>
</div>
Hope this helps! :)
I want to have 6 columns responsive, I create this html but is not so good, maybe someone can give me the correct structure and css. The issue here is when I try to resize the window the icon and text is not resize it.
HTML
<div class="container">
<div class="row">
<div class="header-block col-xs-12">
<div class="block1 col-xs-2">
<span><strong>100% fornøyd</strong>Vårt mål!</span>
</div>
<div class="block2 col-xs-2">
<span><strong>Rask levering</strong>stort lager!</span>
</div>
<div class="block3 col-xs-2">
<span><strong>Serviceverksted</strong>Minimal driftstans!</span>
</div>
<div class="block4 col-xs-2">
<span><strong>Kataloger</strong>Se våre produkter!</span>
</div>
<div class="block6 col-xs-2">
<span><strong>Finansiering</strong>Fleksible løsninger!</span>
</div>
<div class="block5 col-xs-2">
<span><strong>Hold kontakten</strong>Følg oss på facebook!</span>
</div>
</div>
</div>
</div>
CSS:
.header-block > div {
float: left;
position: relative;
margin-right: 10px;
padding: 5px 10px;
max-width: 224px;
}
.header-block span {
display: inline-block;
font-size: 16px;
line-height: 20px;
text-transform: uppercase;
padding-left: 48px;
color: #262626;
}
.header-block strong {
display: block;
}
.header-block > div:before {
font-size: 42px;
line-height: 42px;
color: #faa641;
position: absolute;
left: 10px;
top: 5px;
}
.header-block .block1:before {
content: '\f087';
}
.header-block .block2:before {
content: '\f0d1';
}
.header-block .block3:before {
content: '\f021';
}
.header-block .block4:before {
content: '\f07c';
}
.header-block .block5:before {
content: '\f082';
}
.header-block .block6:before {
content: '\f0d6';
}
Your html is wrong. Cols should always be inside a row. Also, if you modify a col padding or its margins, you will break bootstrap. If you want to touch that you have to do it via the source (less or sass). So that block classes you are adding to the cols, will for sure break bootstrap.
<div class="container">
<div class="row">
<div class="col-xs-12">Whatever you want full row</div>
<div class="col-xs-2">1</div>
<div class="col-xs-2">2</div>
<div class="col-xs-2">3</div>
<div class="col-xs-2">4</div>
<div class="col-xs-2">5</div>
<div class="col-xs-2">6</div>
</div>
</div>
This (above) will give you 6 cols responsive. If you want to nest columns:
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="row">
<div class="col-xs-2">1</div>
<div class="col-xs-2">2</div>
<div class="col-xs-2">3</div>
<div class="col-xs-2">4</div>
<div class="col-xs-2">5</div>
<div class="col-xs-2">6</div>
</div>
</div>
</div>
</div>
If you need each col content to have padding you will have to apply the padding to a child div:
...
<div class="col-xs-2">
<div class="some-padding">
this content will have padding and not break bootstrap
</div>
</div>
I have the following html code:
<div class="text-center">
<div class="row">
<div class="col-md-6">gdshdhfdhfdhfd</div>
<div class="col-md-6"><img src="http://image.com/img.png" alt="cat"></div>
</div>
<h4>header.</h4>
<p>hey there</p>
<div class="paddown">
<a class="btn btn-default" name="close" id="close" >Close</a>
</div>
</div>
And I would like to add any text (e.g. <span id="txt">lorem ipsum</span>)on the picture, let's say around 30-40px from the bottom, so it's visible in front of the cat's picture. Is it possible in bootstrap without using absolute positioning?
Here is my fiddle: http://jsfiddle.net/2wujw71x/3/
The general idea to this approach is to wrap the image in a containing element that will take on the size of the image itself. You also include the overlay element inside the wrapper element.
Apply position: relative; to the wrapper element and apply position: absolute; to the overlay element. The relative positioning on the wrapper element prevents the absolutely positioned element from being positioned outside of the wrapper element which happens to be the same size as our image. We now have a "viewport" for the overlay element that is the same size as the image and positioned over the image.
<div class="container">
<div class="row">
<div class="col-md-6">
<p>
Lorem Ipsum
</p>
</div>
<div class="col-md-6">
<span class="overlay-wrapper">
<img class="img-responsive" src="http://maxcdn.thedesigninspiration.com/wp-content/uploads/2012/01/Just-A-Cat-Playing-The-Violin-l.jpg" alt="Cat"/>
<div class="text-overlay">
Caption
</div>
</span>
</div>
</div>
</div>
.overlay-wrapper {
position: relative;
display: inline-block;
}
.text-overlay {
position: absolute;
width: 80%;
background: rgba( 0, 0, 0, .5 );
top: 75%;
left: 10%;
color: #fff;
text-align: center;
}
#media( min-width: 300px ) {
.text-overlay {
padding: 1em 0;
top: 65%;
}
}
#media( min-width: 550px ) {
.text-overlay {
padding: 2em 0;
}
}
http://jsfiddle.net/o2cjkyow/
I've included some media queries in my example so you can see a demonstration on how to adjust various properties at various viewport sizes for fine-tuning.
Here's my JSFiddle from the comments.
You can use the img-thumbnail class as a base with some minor adjustments, then set your text overlay rules in another class.
See working example in Snippet at Full Page.
html,
body {
margin-top: 50px;
}
.img-thumbnail.overlay {
position: relative;
border: none;
margin: 0;
padding: 0;
}
.img-thumbnail.overlay .caption {
position: absolute;
top: 45%;
left: 0;
margin: 0;
padding: 10px 15px 0 15px;
width: 100%;
color: #fff;
background: rgba(0, 0, 0, 0.3);
}
.img-thumbnail.overlay .caption2 {
position: absolute;
top: 45%;
left: 0;
margin: 0;
padding: 10px 15px 0 15px;
width: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container text-center">
<div class="row">
<div class="col-md-6">
<div class="img-thumbnail overlay">
<img src="http://maxcdn.thedesigninspiration.com/wp-content/uploads/2012/01/Just-A-Cat-Playing-The-Violin-l.jpg" alt="" class="img-responsive">
<div class="caption">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
</div>
</div>
</div>
<div class="col-md-6">
<div class="img-thumbnail overlay">
<img src="http://maxcdn.thedesigninspiration.com/wp-content/uploads/2012/01/Just-A-Cat-Playing-The-Violin-l.jpg" alt="" class="img-responsive">
<div class="caption2">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
</div>
</div>
</div>
</div>
</div>
I suggest using relative positioning instead of absolute, that way your position is always relative to the image and its container.
.my-floating-text{
position: relative;
top: 110px;
left: 0px;
}
And in your html:
<div class="text-center">
<div class="row">
<div class="col-md-6"><div class="my-floating-text">gdshdhfdhfdhfd</div><img src="http://maxcdn.thedesigninspiration.com/wp-content/uploads/2012/01/Just-A-Cat-Playing-The-Violin-l.jpg" alt="cat" />
</div>
</div>
<h4>header.</h4>
<p>hey there</p>
<div class="paddown">
<a class="btn btn-default" name="close" id="close" >Close</a>
</div>
</div>
http://jsfiddle.net/2wujw71x/5/
You can try with position:absolute;
HTML:
<div class="text-center">
<div class="row">
<div class="col-md-6 aclass">
<div class="auto">
gdshdhfdhfdhfd
</div>
</div>
<div class="col-md-6">
<img src="http://maxcdn.thedesigninspiration.com/wp-content/uploads/2012/01/Just-A-Cat-Playing-The-Violin-l.jpg" alt="cat"></div>
</div>
<h4>header.</h4>
<p>hey there</p>
<div class="paddown">
<a class="btn btn-default" name="close" id="close" >Close</a>
</div>
</div>
CSS:
.aclass {
position: absolute;
left: 50%;
}
.auto {
position:relative;
top:50px; /*position to top*/
left:-50%;
z-index:9999;
color:#fff;
}
DEMO
The text always is center! :)
Just want to post an alternative approach, with figure and figcaption. The two elements aren't neccessary, but they do make it nice and semantic. The solution itself still exists in CSS. Using padding and an absolute bottom allows the container to scale with multiple lines of text.
HTML
<figure>
<img src="http://maxcdn.thedesigninspiration.com/wp-content/uploads/2012/01/Just-A-Cat-Playing-The-Violin-l.jpg" alt="cat">
<figcaption>This is cat, playing violin</figcaption>
</figure>
CSS
figure {
position: relative;
display: inline-block;
}
figcaption {
background: rgba(255,255,255,0.3);
box-sizing: border-box;
bottom: 0;
font-weight: bold;
width: 100%;
padding: 10px;
position: absolute;
z-index: 10;
}
http://jsfiddle.net/2wujw71x/10/
So my logic of Div ID's and Classes must be WAY off.
Heres whats going on:
As you can see the blocks which say PS don't align center with the slider (Which is inside a container.
Here is my css:
/*Front Page Buttons */
#frontpage-Button-Cont {
height: 350px;
}
.button-cont {
width: 175px;
float: left;
margin-left: 10px;
margin-top: 10px;
height: 250px;
}
.thumbnail {
color: #fff;
font-size: 5em;
background: #1f4e9b;
width: 175px;
height: 135px;
text-align: center;
}
.pheader {
color: #DC143C;
min-width: 175px;
text-align: center;
}
.paragraph {
text-align: center;
}
#Align-content {
margin: 0 auto;
}
And here is the html:
<div id="frontpage-Button-Cont">
<div id="Align-content">
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
</div>
</div>
My theory is that I'm using classes incorrectly?
Thanks.
You can Add this to your CSS
#frontpage-Button-Cont {
width:100%;
}
#Align-content {
display:table;
}
With this your margin:o auto can work
View This Demo http://jsfiddle.net/VGPeW/
You need to make sure that the containing div (in this case frontpage-Button-Cont) is the same width as your slider above it. Then add the property text-align:center to the container. That should fix your issue.