make div with image and text responsive css and bootstrap - html

I have placed an image and text over the div with background as below
The CSS done for this is as below
#image_container {
background: url('images/1.jpg') no-repeat;
max-width:100%;
height:auto;
text-align: center;
padding: 30px;
margin: 10px;
box-sizing: border-box;
}
.main_image {
height: 220px;
margin:-5px;
}
.text {
padding: 5px;
}
.ltext {
margin-top: -5px;
}
and HTML markup is as below
<a href="blog/<link to post>" style="color:inherit">
<div class="col-sm-4">
<div id="image_container" class="">
<img src="images/blog/1.jpg"
class="main_image" alt=""/>
<div class="text">
<img src="images/dot.png" class="col-sm-12 col-xs-12 col-md-12
col-lg-12" alt="divider" style="max-width:100%"/>
Mouting Memories
<p class="ltext">
<?php echo date('l', $time).', '.date('F', $time).' ' ?><?php echo
date('d', $time).', '.date('Y', $time);?>
</p>
</div>
</div>
</div>
</a>
But with above approach the inside image and text is not getting displayed properly on screen size chnage.It is getting displayed as here
Please help.

#image_container {
background: url('blogpost_bg.jpg') no-repeat;
max-width:100%;
height:auto;
text-align: center;
padding: 30px;
margin: 10px;
box-sizing: border-box;
background-size:100% 100%;
}
.main_image {
height: 220px;
margin:-5px;
}
.text {
padding: 5px;
}
.ltext {
margin-top: -5px;
}
Add background-size:100% 100%; to your CSS for the #image_container
Your HTML and PHP
<a href="blog/<link to post>" style="color:inherit">
<div class="col-sm-4">
<div id="image_container" class="">
<img src="images/blog/1.jpg"
class="main_image" alt=""/>
<div class="text">
<img src="images/dot.png" class="col-sm-12 col-xs-12 col-md-12
col-lg-12" alt="divider" style="max-width:100%"/><br>
Mouting Memories
<p class="ltext">
<?php echo date('l', $time).', '.date('F', $time).' ' ?><?php echo
date('d', $time).', '.date('Y', $time);?>
</p>
</div>
</div>
</div>
</a>
Add a <br> after the image (<img>) so the test is forced to the next line even if it has enough space to fit on the same line as the image
Also your PHP isnt very good.
It should rather be
<?php echo date('l, F d, Y', $time);?>
That's the quick way to do it. The better way to do it is to use CSS for the background instead of that image you have used because that image stretches and pixelates. See below for better CSS using -webkit-box-shadow,-moz-box-shadow and box-shadow instead of a background image.
#image_container {
-webkit-box-shadow: 2px 2px 17px 5px rgba(0,0,0,0.37);
-moz-box-shadow: 2px 2px 17px 5px rgba(0,0,0,0.37);
box-shadow: 2px 2px 17px 5px rgba(0,0,0,0.37);
max-width:100%;
height:auto;
text-align: center;
padding: 30px;
margin: 10px;
box-sizing: border-box;
}
Looks cleaner with that CSS

Related

how to create three pic slider

I want to show three pics in my slider but currently it shows only one. My slider image -> https://i.imgur.com/el4KXxl.jpg .But I am trying to make like that. Original slider image -> https://i.imgur.com/gdMj6TC.jpg. Here is my html CSS code.
<style>
.wrapper{
width: 100%;
}
.carousel{
max-width: 1200px;
margin: auto;
padding: 0 30px;
}
.carousel .card{
color: #fff;
text-align: center;
margin: 20px 0;
line-height: 250px;
font-size: 90px;
font-weight: 600;
border-radius: 10px;
box-shadow: 0px 4px 15px rgba(0,0,0,0.2);
}
.carousel .card-1{
background: #ed1c24;
}
.carousel .card-2{
background: #0072bc;
}
.carousel .card-3{
background: #39b54a;
}
.carousel .card-4{
background: #f26522;
}
.carousel .card-5{
background: #630460;
}
</style>
<div class="wrapper" style="margin-top:50px; width:100%;">
<div class="carousel owl-carousel">
<div class="card card-1">
A
</div>
<div class="card card-2">
B
</div>
<div class="card card-3">
C
</div>
<div class="card card-4">
D
</div>
<div class="card card-5">
E
</div>
</div>
</div>

what can i do to stay a dynamic list?

i was making a page of products and i'm having some difficulty, the text makes the box bigger and then disturbs the rest and looks just like the picture. I thank anyone who can help, as long as loyate remains responsive, that aligns according to the resolution.
thanks
normal
decreases resolution and changes position
<section class="col-xs-10 col-xs-offset-1 boxContent destaques">
<div class="col-xs-12">
#foreach ( $produtos as $produto )
<div class="col-xs-12 col-sm-4 col-md-3 boxProduto">
<!--<a href="{{ route('produto', $produto->id_produto) }}">-->
<a href="{{ route('produto', $produto->id_produto) }}">
<div class="col-xs-12 imgProd ">
<img src="{{ $produto->url_imagem }}" class="img-responsive" >
</div>
</a>
<span style=" overflow-wrap: break-word;
padding: 15px;
word-wrap: break-word;
margin: center;">
{{ $produto->nome }}
</span>
<div class="col-md-12 preco">
<p>{{ $produto->pvp }}€</p>
</div>
<div class="col-xs-12 detalhes">
DETALHES
</div></div>
</div>
#endforeach
<!--</a>-->
</section>
<style>
.boxProduto {
padding: 0px !important;
margin: 10px 1%;
border: 1px solid #ccc;
border-radius: 2px ;display: block;
text-align: center;
}
.destaques {
h1 {
width: 60%;
}
.hr {
width: 21%;
}
.boxContent {
padding: 15px 25px !important;
margin-bottom: 15px;
background: white;
box-shadow: 0px 0px 11px #ddd;
width: 100%;
float: left;
margin-bottom: 0px;
text-align: center;}
</style>

Vertical aligning of pictures with links inside a div

I've been struggling with this simple and basic problem for the last day and can't seem to find a solution for it nowhere.
I'm having a container div on my website, in which there are four social network buttons, and what I'm trying to achieve is vertically align them in to the middle
of the container, so there's equal amount of free space on top of them and underneath them.
Please note, that I've linke normalize.css and reset.css to my html.
Muh code:
HTML
<div class="social-line-container">
<div class="social-line-buttons-group">
<a href="#0"><img src="socialicons/facebook.png" alt="FB"><a/>
<a href="#0"><img src="socialicons/twitter.png" alt="TW"><a/>
<a href="#0"><img src="socialicons/google.png" alt="GO"><a/>
<a href="#0"><img src="socialicons/youtube.png" alt="YT"><a/>
</div>
</div>
CSS
.social-line-container {
width: 66%;
height: inherit;
margin: 0 auto;
}
.social-line-buttons-group a{
display: inline-block;
vertical-align: middle;
height: 100%;
float: right;
padding: 2px;
margin: 0 3px;
}
Any help will be much appreciated.
All you need to add is clear
.social-line-container {
width: 66%;
height: inherit;
margin: 0 auto;
}
.social-line-buttons-group a {
display: inline-block;
/*vertical-align: middle;*/
height: 100%;
float: right;
clear: both; /* add */
padding: 2px;
margin: 0 3px;
}
<div class="social-line-container">
<div class="social-line-buttons-group">
<a href="#0">
<img src="socialicons/facebook.png" alt="FB"><a/>
<a href="#0">
<img src="socialicons/twitter.png" alt="TW"><a/>
<a href="#0">
<img src="socialicons/google.png" alt="GO"><a/>
<a href="#0">
<img src="socialicons/youtube.png" alt="YT"><a/>
</div>
</div>
.social-line-container{
border:2px solid black;
}
.social-line-buttons-group{
display:flex;
align-items: center;
justify-content: center;
height:100%;
}
.social-line-buttons-group a{
padding: 2px;
margin: 0 3px;
}
img{
width:50px;
height:50px;
}
<div class="social-line-container">
<div class="social-line-buttons-group">
<img src="http://lh3.googleusercontent.com/-ElsaNCI_yKg/VcXI_VFictI/AAAAAAAAINA/MeFjL1Ymaac/s640/StylzzZ%252520%252528289%252529.png" alt="FB">
<img src="https://upload.wikimedia.org/wikipedia/it/archive/0/09/20160903181541!Twitter_bird_logo.png" alt="TW">
<img src="http://www.userlogos.org/files/logos/annyella/google3.png" alt="GO">
<img src="http://logok.org/wp-content/uploads/2014/08/YouTube-logo-play-icon-219x286.png" alt="YT">
</div>
</div>

Two inline images. CSS / HTML

I am creating website for my school (its something like match) but I am stuck on one thing :/ . I am trying to inline 2 images. One is for decoration and secound is like board for text. And its working but border is not comming down O.o and its under a div main (glavendrzac on my language) . Margin is working but border not. Its only "bordering" around logo :/ (See image below.)
http://prntscr.com/b0qtw7
<html>
<head>
<meta charset="UTF-8"/>
<title>ООУ "Јосип Броз Тито"</title>
<link rel="stylesheet" type="text/css" href="stilovi.css">
</head>
<body>
<div id = "glavendrzac">
<div class = "logopozicija">
<img src="sliki/logo.png"/>
</div>
<div id = "sliki">
<div class = "profesor">
<img src="sliki/profesor.png" width="270px"; height="450px";/>
</div>
<div id = "tabla">
<div class = "tablatekst">
test
</div>
</div>
</div>
</div>
<?php
//
?>
</body>
</html>
And this is CSS code
body
{
margin: 10px;
}
#glavendrzac
{
margin-left: 200px;
margin-right: 200px;
border: 2px solid black;
border-radius: 8px;
}
#sliki
{
}
.profesor
{
float:left;
}
#tabla
{
margin-top:50px;
float:right;
margin-left:30px;
border: 0px solid black;
border-radius:20px;
width: 800px;
background: url("sliki/tabla.png");
background-size: cover;
}
.tablatekst
{
margin-top: 30px;
margin-left: 40px;
margin-bottom: 30px;
margin-right: 40px;
}
Can someone help me :) IDK whats wrong.
If you add overflow: auto to the #glavendrzac then the floats will be contained within the containing div, which I think is what you need.
You will need to think about the widths of the various child elements to make sure that the professor image and text box fit within the parent container.
The CSS concept involved here is known as a block formatting context.
Reference: https://www.w3.org/TR/CSS2/visuren.html#block-formatting
#glavendrzac {
margin-left: 200px;
margin-right: 200px;
border: 2px solid black;
border-radius: 8px;
overflow: auto;
}
#sliki {}
.profesor {
float: left;
}
#tabla {
margin-top: 50px;
float: right;
margin-left: 30px;
border: 1px solid black;
border-radius: 20px;
}
.tablatekst {
margin-top: 30px;
margin-left: 40px;
margin-bottom: 30px;
margin-right: 40px;
}
<div id="glavendrzac">
<div class="logopozicija">
<img src="http://placehold.it/50x50" />
</div>
<div id="sliki">
<div class="profesor">
<img src="http://placehold.it/100x450" width="100px" ; height="450px" ;/>
</div>
<div id="tabla">
<div class="tablatekst">
test (this needs some work)
</div>
</div>
</div>
</div>

Position:absolute bottom right alignment

I am trying to align my 40px40px image to bottom right. I've tried this, worked fine, but if I use another back image, it doesn't fit to bottom right. How can I avoid this problem ?
<div style="width:179px;margin-right:9px;padding-bottom:10px;background-color:white;border:1px solid #c9d2d6;padding:4px;padding-bottom:7px;border-radius:4px;position:relative">
<img src="http://media-cache-ec4.pinterest.com/upload/212443307392484250_XX0wNZSy_b.jpg" style="width:179px;" \>
<div style="position:absolute;z-index:5;top:73%;left:75%;width:40px;height:40px;border:1px solid #333333;">
<img width=40 src="http://media-cache-ec4.pinterest.com/avatars/baduizm1974-1346279934.jpg" \>
</div>
<div style="border-radius:6px;width:179px;border-top:0px;position:relative;background-color:white;">
<div style="text-align:left;padding-left:6px;padding-right:5px;padding-top:3px;">Fragments by textile artist Lorenzo Nanni (2001) </div>
</div>
</div>
UPDATE:
That said, you should use a mix of CSS and HTML instead:
HTML:
<div class="container">
<div class="picture-container">
<img src="http://media-cache-ec4.pinterest.com/upload/212443307392484250_XX0wNZSy_b.jpg" class="background-picture" \>
<div class="avatar">
<img src="http://media-cache-ec4.pinterest.com/avatars/baduizm1974-1346279934.jpg" \>
</div>
</div>
<div class="container-text">
<div>Fragments by textile artist Lorenzo Nanni (2001)<br />More text</br />Goes here</div>
</div>
</div>​
CSS:
.container {
width: 179px;
margin-right: 9px;
padding-bottom: 10px;
background-color: white;
border: 1px solid #c9d2d6;
padding: 4px;
padding-bottom: 7px;
border-radius: 4px;
position: relative;
}
.container .picture-container {
position: relative;
min-height: 60px;
}
.container .background-picture {
width: 179px;
}
.container .avatar {
position: absolute;
z-index: 5;
bottom: 10px;
right: 5px;
width: 40px;
height: 40px;
border: 1px solid #333333;
}
.container .avatar img {
width: 40px;
}
.container .container-text {
border-radius: 6px;
width: 179px;
border-top: 0px;
position: relative;
background-color: white;
}
.container .container-text div {
text-align: left;
padding-left: 6px;
padding-right: 5px;
padding-top: 3px;
}​
This also fixed the problem in the comment below.
DEMO
Old post, that explains why you have a problem in the first place and doesn't account for taller text:
In
<div style="position:absolute;z-index:5;top:73%;left:75%;width:40px;height:40px;border:1px solid #333333;">
<img width=40 src="http://media-cache-ec4.pinterest.com/avatars/baduizm1974-1346279934.jpg" \>
</div>
instead of
top:73%;left:75%; then use bottom and right like so: bottom: 60px;right: 10px;
Full example:
<div style="width:179px;margin-right:9px;padding-bottom:10px;background-color:white;border:1px solid #c9d2d6;padding:4px;padding-bottom:7px;border-radius:4px;position:relative">
<img src="http://media-cache-ec4.pinterest.com/upload/212443307392484250_XX0wNZSy_b.jpg" style="width:179px;" \>
<div style="position:absolute;z-index:5;bottom: 60px;right: 10px;width:40px;height:40px;border:1px solid #333333;">
<img width=40 src="http://media-cache-ec4.pinterest.com/avatars/baduizm1974-1346279934.jpg" \>
</div>
<div style="border-radius:6px;width:179px;border-top:0px;position:relative;background-color:white;">
<div style="text-align:left;padding-left:6px;padding-right:5px;padding-top:3px;">Fragments by textile artist Lorenzo Nanni (2001) </div>
</div>
</div>​
DEMO
You have to put it inside a container, then make the image a block to avoid the space under it. Note that using properties right & bottom are a better solution than left and top.
http://jsfiddle.net/Ka4r4/