I have these 3 column images with title, caption ad icon that I couldn't align properly. Is there way fix the caption and title text according to the image width? What is the best practice to deal with these kind of content? Should I align the CSS for each screen size ?
#import url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css');
.urun-text {
position: absolute;
background-color: rgba(15, 15, 15, 0.93);
color: #fff;
bottom: 0px;
text-align: left;
padding: 20px 15px 20px 15px;
}
.urun-title {
position: absolute;
bottom: 80px;
text-align: left;
z-index: 15;
padding-top: 5px;
padding-bottom: 5px;
color: #fff;
padding-left: 20px;
text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
background-color: rgba(194, 0, 0, 0.93);
width: 100%;
}
.click-arrow-right {
position: absolute;
z-index: 16;
color: #fff;
font-size: 10px;
bottom: 0px;
right: 33px;
}
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="product-box">
<img src="http://i.imgur.com/xkAVZ3b.jpg" alt="Yeni Ürünler" class="align-center img-responsive">
<div class="urun-title"><span class="glyphicon glyphicon-star"></span> YENİ ÜRÜNLER</div>
<div class="urun-text">En yeni mobilya konseptlerini görmek için tıklayınız.</div>
<div class="click-arrow-right"><span class="glyphicon glyphicon-arrow-right"></span>
</div>
</div>
</div>
<div class="col-md-4">
<div class="product-box">
<img src="http://i.imgur.com/xkAVZ3b.jpg" alt="Yeni Ürünler" class="align-center img-responsive">
<div class="urun-title"><span class="glyphicon glyphicon-star"></span> YENİ ÜRÜNLER</div>
<div class="urun-text">En yeni mobilya konseptlerini görmek için tıklayınız.</div>
<div class="click-arrow-right"><span class="glyphicon glyphicon-arrow-right"></span>
</div>
</div>
</div>
<div class="col-md-4">
<div class="product-box">
<img src="http://i.imgur.com/xkAVZ3b.jpg" alt="Yeni Ürünler" class="align-center img-responsive">
<div class="urun-title"><span class="glyphicon glyphicon-star"></span> YENİ ÜRÜNLER</div>
<div class="urun-text">En yeni mobilya konseptlerini görmek için tıklayınız.</div>
<div class="click-arrow-right"><span class="glyphicon glyphicon-arrow-right"></span>
</div>
</div>
</div>
</div>
</div
Here you go
http://jsfiddle.net/ajruk60t/3/
.product-box {
display:inline-block;
position:relative;
}
.urun-title {
width:100%;
}
.urun-text {
width:100%;
}
Setting the display to inline-block allows the .product-box to only be as wide as it's content (namely,the image), and position:relative allows us to set the width of the nested .urun-title and .urun-text elements to be 100% of the width of the .product-box.
Related
I have a row of cards that are sized so that two fit to the width of the screen then the next two appear below.
I am struggling to get the top of the #card row to be 10px below the #title-row above and to be at the bottom of the #main-container and scrolling if the screen isn't tall enough.
#card-row {
position: relative;
overflow: scroll;
width: 98%;
margin: 0;
bottom: 0;
}
#main-container {
overflow: hidden;
height: 100%;
width: 100%;
}
#title-text {
margin-top: 15px;
margin-bottom: 0px;
font-size: 80px;
color: black;
font-family: "CallingAngelsPersonalUse";
text-shadow: 4px 6px 12px #fff;
}
#date-text {
margin-top: -20px;
margin-bottom: 0px;
font-size: 45px;
color: black;
font-family: "Strawberry_Whipped_Cream";
text-shadow: 2px 4px 6px #fff;
}
#card-title {
font-family: "CallingAngelsPersonalUse";
font-size: 30px;
left: -5px;
bottom: -20px;
}
<div id="main-container" class="container">
<div id="title-row" class="row">
<div class="container center">
<div class="show-on-medium-and-up hide-on-small-only">
<p id="title-text">Scott and Viki</p>
<p id="date-text">23rd June 2018</p>
<a id="button" class="black waves-effect waves-light btn z-depth-3" href="mailto:who#gmail.com?subject=Wedding%20R.S.V.P"><i class="material-icons right">email</i>R.S.V.P</a>
</div>
</div>
</div>
<!-- Agenda Card -->
<div id="card-row" class="row">
<div class="col s12 m6">
<a href="#" onclick="$('#agenda-modal').modal('open');">
<div class="card">
<div class="card-image">
<img src="./assets/SVSunset.jpg" class="z-depth-4">
<span id="card-title" class="card-title">Order of the day</span>
</div>
</div>
</a>
</div>
<!-- Map Card -->
<div class="col s12 m6">
<a href="#" onclick="$('#map-modal').modal('open');" role="button" (click)="openChurchMap()">
<div class="card">
<div class="card-image">
<img src="./assets/1.jpg" class="z-depth-4">
<span id="card-title" class="card-title">Map's and Directions</span>
</div>
</div>
</a>
</div>
6 more cards as above
</div>
Currently, everything is where it should be but when you scroll the cards only move 10px or so. How can I fix this so its dynamic for all screens? Also the #card-row is hugging to the left which i cant get to center either?
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;
}
While I hover Div tag, Another Div tag will appear in front of the prev Div. When i didn't put any words, it works. but when i put h3 tag, the div goes down.
here is the HTML
<div id="content">
<h1 class="head-content">Biscuits</h1>
<div class="line"></div>
<a href="#">
<div class="list-content">
<div class="detail-content">
<h3>Biscuits 1</h3>
<p>Price: IDR 12000</p>
</div>
</div>
</a>
<a href="#">
<div class="list-content">
<div class="detail-content">
</div>
</div>
</a>
<a href="#">
<div class="list-content">
<div class="detail-content">
</div>
</div>
</a>
</div>
here is CSS
#content{
width:50%;
}
.line{
border-top: 5px solid black;
}
.list-content{
display:inline-block;
width:25%;
height:200px;
background-color: black;
margin-top: 10px;
}
.detail-content{
display: none;
}
.list-content:hover .detail-content{
display: block;
width:100%;
height:75%;
background-color: rgba(255,255,255,0.6);
}
thank you before
Update below css part
.list-content:hover .detail-content {
display: table;
width: 100%;
height: 75%;
background-color: rgba(255, 255, 255, 0.6);
}
#content {
width: 50%;
}
.line {
border-top: 5px solid black;
}
.list-content {
display: inline-block;
width: 25%;
height: 200px;
background-color: black;
margin-top: 10px;
}
.detail-content {
display: none;
}
.list-content:hover .detail-content {
display: table;
width: 100%;
height: 75%;
background-color: rgba(255, 255, 255, 0.6);
}
<div id="content">
<h1 class="head-content">Biscuits</h1>
<div class="line"></div>
<a href="#">
<div class="list-content">
<div class="detail-content">
<h3>Biscuits 1</h3>
<p>Price: IDR 12000</p>
</div>
</div>
</a>
<a href="#">
<div class="list-content">
<div class="detail-content">
</div>
</div>
</a>
<a href="#">
<div class="list-content">
<div class="detail-content">
</div>
</div>
</a>
</div>
#James Please find following code. I hope you are expecting the same. Just replaced "display:inline-block;" with "float:left;" and took class "list-content" in anchor tag itself.
#content{
width:50%;
}
.line{
border-top: 5px solid black;
}
.list-content{
float:left;
width:25%;
height:200px;
background-color: black;
margin-top: 10px;
margin-right:10px;
}
.detail-content{
display: none;
}
.list-content:hover .detail-content{
display: block;
width:100%;
height:75%;
background-color: rgba(255,255,255,0.6);
}
.clearfix{
clear:both;
}
<div id="content">
<h1 class="head-content">Biscuits</h1>
<div class="line"></div>
<div class="clearfix">
<a href="#" class="list-content">
<div class="detail-content">
<h3>Biscuits 1</h3>
<p>Price: IDR 12000</p>
</div>
</a>
<a href="#" class="list-content">
<div class="detail-content">
</div>
</a>
<a href="#" class="list-content">
<div class="detail-content">
</div>
</a>
</div>
</div>
Because the .list-content items are inline blocks, when you add a text content you have to vertically align them. Add vertical-align: top to .list-content:
.list-content {
display: inline-block;
width: 25%;
height: 200px;
background-color: black;
margin-top: 10px;
vertical-align: top;
}
And remove the top margin from :
h3 {
margin-top: 0;
}
{
width: 50%;
}
.line {
border-top: 5px solid black;
}
.list-content {
display: inline-block;
width: 25%;
height: 200px;
background-color: black;
margin-top: 10px;
vertical-align: top;
}
.detail-content {
display: none;
width: 100%;
height: 75%;
background-color: rgba(255, 255, 255, 0.6);
}
.list-content:hover .detail-content {
display: block;
}
h3 {
margin-top: 0;
}
<div id="content">
<h1 class="head-content">Biscuits</h1>
<div class="line"></div>
<a href="#">
<div class="list-content">
<div class="detail-content">
<h3>Biscuits 1</h3>
<p>Price: IDR 12000</p>
</div>
</div>
</a>
<a href="#">
<div class="list-content">
<div class="detail-content">
</div>
</div>
</a>
<a href="#">
<div class="list-content">
<div class="detail-content">
</div>
</div>
</a>
</div>
Sorry if this is a duplicate question, but I couldn't find an exact match to this which worked, so here it goes.
I have a web page with divs for each database entry. However, the div doesn't resize with text, causing the text to display out of div. I'm using bootstrap.
I've attached a fiddle.
Increase the width of the fiddle output to see the overflowing text.
Currently, i'm working on just the desktop version, but i'll have to build a mobile version as well. So it'll be better if you can help me out with both :)
Below is my code
.each-entry-box {
min-height: 80px;
max-height: 110px;
width: 80%;
background: #F5F5F5;
margin: 10px;
border-radius: 5px;
position: relative;
}
.each-entry-box-header {
height: auto;
width: 100%;
background: #E6E6FA;
margin: 0;
border-radius: 5px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
position: absolute;
padding: 2px;
}
.main-content {
margin: 15px;
top: 30px;
position: relative;
width: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="each-entry-box">
<div class="each-entry-box-header">
<div class="col-md-9 customer-name">
<i class="glyphicon glyphicon-user glyphicon-class"></i><span>customer name</span>
</div>
<div class="col-md-3 added-on">
<i class="glyphicon glyphicon-time glyphicon-class"></i><span>time</span>
</div>
</div> <!-- each-entry-box-header ends here -->
<div class="main-content">
<div class="col-md-12">
<div class="col-md-3 customer-mobile">
<i class="glyphicon glyphicon-earphone glyphicon-class"></i><span>mobile number</span>
</div>
<div class="col-md-9 customer-email">
<i class="glyphicon glyphicon-envelope glyphicon-class"></i><span>No email ID added</span>
</div>
</div>
<div class="col-md-12">
Material : None
</div>
<div class="col-md-12">
<div class="col-md-4">
XYZ : None
</div>
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
</div>
</div>
</div>
Here's a working JS Fiddle,
I've floated both divs and removed the absolute positioning, I've also changed the background colour from the parent element to the child element, so as the list grows, the background will too
HTML:
<div class="each-entry-box">
<div class="each-entry-box-header">
<div class="col-md-9 customer-name">
<i class="glyphicon glyphicon-user glyphicon-class"></i><span>customer name</span>
</div>
<div class="col-md-3 added-on">
<i class="glyphicon glyphicon-time glyphicon-class"></i><span>time</span>
</div>
</div> <!-- each-entry-box-header ends here -->
<div class="main-content">
<div class="col-md-12">
<div class="col-md-3 customer-mobile">
<i class="glyphicon glyphicon-earphone glyphicon-class"></i><span>mobile number</span>
</div>
<div class="col-md-9 customer-email">
<i class="glyphicon glyphicon-envelope glyphicon-class"></i><span>No email ID added</span>
</div>
</div>
<div class="col-md-12">
Material : None
</div>
<div class="col-md-12">
<div class="col-md-4">
XYZ : None
</div>
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
</div>
</div>
</div>
CSS:
.each-entry-box{
min-height: 80px;
max-height: 110px;
width: 80%;
background: #F5F5F5;
margin: 10px;
border-radius: 5px;
position: relative;
}
.each-entry-box-header{
height: auto;
width: 100%;
background: #E6E6FA;
margin: 0;
border-radius: 5px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
/* position: absolute; */
padding: 2px;
float: left;
}
.main-content{
/* margin: 15px; */
/* top: 30px; */
/* position: relative; */
width: 100%;
background: #F5F5F5;
float: left;
clear: left;
}
.main-content should not have relative position. For mobile responsive styles, you can use col-sm- and col-xs-:
.each-entry-box {
min-height: 80px;
max-height: 110px;
width: 80%;
background: #F5F5F5;
margin: 10px;
border-radius: 5px;
position: relative;
}
.each-entry-box-header {
height: auto;
width: 100%;
background: #E6E6FA;
margin: 0;
border-radius: 5px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
position: absolute;
padding: 2px;
}
.main-content {
margin: 15px;
margin-top: 25px;
width: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="each-entry-box row">
<div class="each-entry-box-header">
<div class="col-md-9 customer-name col-sm-9 col-xs-8">
<i class="glyphicon glyphicon-user glyphicon-class"></i><span>customer name</span>
</div>
<div class="col-md-3 added-on col-sm-3 col-xs-4">
<i class="glyphicon glyphicon-time glyphicon-class"></i><span>time</span>
</div>
</div> <!-- each-entry-box-header ends here -->
<div class="main-content">
<div class="col-md-12">
<div class="col-md-3 customer-mobile col-sm-3">
<i class="glyphicon glyphicon-earphone glyphicon-class"></i><span>mobile number</span>
</div>
<div class="col-md-9 customer-email col-sm-9">
<i class="glyphicon glyphicon-envelope glyphicon-class"></i><span>No email ID added</span>
</div>
</div>
<div class="col-md-12">
Material : None
</div>
<div class="col-md-12">
<div class="col-md-4">
XYZ : None
</div>
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
</div>
</div>
</div>
I'm trying to make a vertical line between my div.
I want to my line to fit the whole height of the div, I couldn't get to do that.
I've tried border-right, and border-left of the next div.
Here is my my results
border-right
border-left of the next div
Can someone please show me the best way to accomplish this ?
Thanks in advance.
CODE
<style type="text/css">
.panel {
border-radius: 0px !important;
background-color: #4D8FCB;
color: white;
margin-left: 25px;
margin-right: 25px;
}
.panel-heading {
height: 114px;
}
.panel-body {
font-size: 10px;
background-color: white;
}
.sa-h1 {
color: white;
font-size: 39px;
font-weight: bold;
font-style: normal;
font-family: "adelle-sans", sans-serif;
}
.sa-h2{
font-size: 28px;
}
.sa-h3{
font-size: 16px;
}
.sa-h4{
font-size: 14px;
}
.sa-h5{
font-size: 12px;
}
.sa-h6{
font-size: 10px;
}
.sa-right-items{
float: left;
/*line-height: 114px;*/
}
.sa-answer, .sa-score, .sa-review, .sa-report {
vertical-align: middle;
display: inline-block;
padding: 5px 22px;
}
</style>
<br><br>
<div class="row student-accordion ">
<div class="col-md-12">
<div class="panel-group" id="accordion">
<div class="panel">
<div class="row panel-heading">
<div class="panel-title">
<div class="col-xs-1 sa-section" >
<p><span class="sa-h5">SECTION</span>
<br>
<span id="sa-section-num" class="sa-h1">2.2</span>
<br><span class="sa-h5">EXERCISE</span>
</p>
</div>
<!-- Title -->
<div class="col-xs-6 col-lg-6" style="border-left: 2px solid white;" >
<span class="sa-h3">Section Exercise 2.2</span><br>
<span class="sa-h5">ALGEBRA 1</span> <br>
<span class="sa-h4">02/09/2015</span>
</div>
<!-- Answers -->
<div class="sa-right-items text-center">
<span class="sa-answer">
<span> <span class="sa-h2">11/25</span> <br> <span class="sa-h6">ITEMS ANSWERED <br> CORRECTLY</span> </span>
</span>
<!-- Score -->
<span class="sa-score">
<span> <span class="sa-h2">44%</span> <br> <span class="sa-h6">SCORE</span> </span>
</span>
<!-- Review -->
<span class="sa-review">
<img width="40px" src="/BIM/resources/images/icons-report/review_white.png"><br>
<span> <span class="sa-h6">REVIEW</span> </span>
</span>
<!-- Report -->
<span class="sa-report">
<span data-toggle="collapse" data-parent="#accordion" href="#student-accordion-collapse" class="pull-right">
<img width="40px" src="/BIM/resources/images/icons-report/report_white.png"><br>
<span> <span class="sa-h6">VIEW REPORT</span> </span>
</span>
</span>
</div>
</div>
</div>
<div id="student-accordion-collapse" class="panel-collapse collapse">
<div class="panel-body">
Contents
</div>
</div>
</div>
</div>
</div>
</div>
JSFiddle
Remove the border style from .col-xs-6 col-lg-6, then:
.col-xs-1 sa-section {
border-right: 2px solid #fff;
margin-top: -11px;
padding-top: 11px;
}
Basically the border will show up within padding, so you just need to move the container up a bit (using a negative margin-top) and add some padding so the text shows up in the same place.
You will probably want to add an ID to the container and target it in CSS that way, instead of defining the styles of the class.
JSFiddle
Please check the fiddle - http://jsfiddle.net/onms9kcu/3/
border inline style removed, and added the below style.
.sa-section:after{
border-right: 2px solid white;
content: "";
display: block;
width: 1px;
position: absolute;
bottom: -10px;
top: -10px;
right: 0;
}