Aligning Three Images Horizontally (Can only get them vertical) - html

I seem to be really missing something about how to line three images horizontally in one block across the screen with CSS. I seem to only be able to line them up in one long line down the page (when I really want them to go across the screen in a horizontal line). Where am I doing wrong with my div? Or maybe I am being led astray in CSS? Any ideas? Thank you so much.
.taco_container {
width: 300px;
height: 300px;
position: absolute;
left: 50%;
top: 50%;
margin-left: auto;
margin-right: auto;
}
<div id="taco_container">
<div class="taco">
<a href="tacogame_choose_1.html">
<img src="images/tacoone.png" style="width:304px;height:228px">
</a>
</div>
<div class="taco">
<a href="tacogame_choose_2.html">
<img src="images/tacotwo.png" style="width:304px;height:228px">
</a>
</div>
<div class="taco">
<a href="tacogame_choose_3.html">
<img src="images/tacothree.png">
</a>
</div>
</div>

your solution may be: demo
i added only class :"img_class" and remove inline style sheet
.taco_container {
width: 300px;
height: 300px;
position: absolute;
left: 50%;
top: 50%;
margin-left: auto;
margin-right: auto;
}
.img_class{width:33%;
float:left;
height:auto;
}
<div id="taco_container">
<div class="taco">
<a href="tacogame_choose_1.html">
<img class="img_class" src="images/tacoone.png">
</a>
</div>
<div class="taco">
<a href ="tacogame_choose_2.html">
<img class="img_class" src="images/tacotwo.png" >
</a>
</div>
<div class="taco">
<a href="tacogame_choose_3.html">
<img class="img_class" src="images/tacothree.png">
</a>
</div>
</div>

You have to display items as inline-block and set text-align: center.
.taco_container {
width: 100%;
}
.taco {
width: 33%;
display: inline-block;
text-align: center;
}
Fiddle: http://jsfiddle.net/2xo1gr6w/

Check here an example also with display:inline : http://jsfiddle.net/y1tuLyzg/
#taco_container {
width: 300px;
height: 300px;
position: absolute;
left: 50%;
top: 50%;
margin-left: auto;
margin-right: auto;
padding:0;
}
#taco_container .taco {
display:inline-block;
width:33%;
height:100px;
}
#taco_container .taco img {
max-width:100%;
margin:0;
padding:0;
}

Almost! You just needed to add display:inline-block; to .taco:
.taco {
display:inline-block;
}
EXAMPLE (excuse the kittens they are an example)
Also taco_container has a width of 300px and each image has a width of 304px, so you would need to increase the width of taco_container accordingly to fit with the images.

.taco_container {
width: 300px; <!-- wrapping div is smaller than the divs you trying to put in it-->
height: 300px;
position: absolute;
left: 50%;
top: 50%;
margin-left: auto;
margin-right: auto;
}
<div id="taco_container">
<div class="taco">
<a href="tacogame_choose_1.html">
<img src="images/tacoone.png" style="width:304px;height:228px">
</a>
</div>
<div class="taco">
<a href="tacogame_choose_2.html">
<img src="images/tacotwo.png" style="width:304px;height:228px">
</a>
</div>
<div class="taco">
<a href="tacogame_choose_3.html">
<img src="images/tacothree.png">
</a>
</div>
</div>
Your wrapping div or container is 300px yet you are trying to put 3 divs that are 304px wide into it.

.taco_container {
width: 100%;
height: 300px;
position: absolute;
left: 50%;
top: 50%;
margin-left: auto;
margin-right: auto;
}
.taco { display: inline-block;
width:30%;}
<div id="taco_container">
<div class="taco">
<a href="tacogame_choose_1.html">
<img src="images/tacoone.png" style="height:228px">
</a>
</div>
<div class="taco">
<a href="tacogame_choose_2.html">
<img src="images/tacotwo.png" style="height:228px">
</a>
</div>
<div class="taco">
<a href="tacogame_choose_3.html">
<img src="images/tacothree.png">
</a>
</div>
</div>

Related

I am trying to create an Image Slider, but when I set the position of the angle left icon to ABSOLUTE, it disappears from the screen

The angle left icon basically disappears when I set its position to absolute, but it remains otherwise.
Here the angle left icon is not visible due its position property. How can it appear on the screen so that I can position it on the top left part of the image, so as to make an image slider.
This is my html code:
<section>
<div class="team">
<div>
<h1 id="teamtext">Our Team and Contributers</h1>
</div>
<div class="content">
<div class="imageslider">
<img src="assets/photo1.jpg">
<img src="assets/photo2.jpg">
<img src="assets/photo3.jpg">
<img src="assets/photo4.jpg">
<img src="assets/photo5.jpg">
</div>
</div>
<div class="slideleft">
<i class="uil uil-angle-left"></i>
</div>
<div class="slideright">
<i class="uil uil-angle-right"></i>
</div>
</div>
</section>
and this is my CSS code:
.content{
height: 400px;
width: 750px;
overflow: hidden;
}
.imageslider{
height: 100%;
width: 100%;
}
.imageslider img{
width: 100%;
height: 100%;
object-fit: cover;
}
.slideleft{
color: red;
font-size: 100px;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.slideright{
color: red;
font-size: 100px;
}
I searched similar questions in the internet but they aren't working.
It appears while having position: absolute;. Please see my codesnippet:
<style type="text/css">.content {
height: 400px;
width: 750px;
overflow: hidden;
border: solid;
}
.imageslider {
height: 100%;
width: 100%;
border: solid;
display: flex;
flex-wrap: wrap;
}
.imageslider img {
width: 50%;
height: calc(400px / 3);
object-fit: cover;
}
.slideleft {
color: red;
font-size: 100px;
position: absolute;
top: 15%;
}
.slideright {
color: red;
font-size: 100px;
}
<section>
<div class="team">
<div>
<h1 id="teamtext">Our Team and Contributers</h1>
</div>
<div class="content">
<div class="imageslider">
<img src="https://s4.uupload.ir/files/1-6-5_ssnb.jpg">
<img src="https://s4.uupload.ir/files/1-6-5_ssnb.jpg">
<img src="https://s4.uupload.ir/files/1-6-5_ssnb.jpg">
<img src="https://s4.uupload.ir/files/1-6-5_ssnb.jpg">
<img src="https://s4.uupload.ir/files/1-6-5_ssnb.jpg">
</div>
</div>
<div class="slideleft">
<i class="uil uil-angle-left">slideleft</i>
</div>
<div class="slideright">
<i class="uil uil-angle-right">slideright</i>
</div>
</div>
</section>

How can I center and left align images?

I am working on an image gallery and want have the image's container be completely centered on the page, but the images are left aligned.
This is my desired output:
However, when I try to do a text-align: center on the container(id: gallery) I am getting the images displayed like this:
I tried following suit with a previous stack overflow question: CSS: Center block, but align contents to the left
and wrap the images in another div then align it with display: inline-block; and text-align: left; but the images just seem to align left on the entire page:
What can I do to accomplish my desired output?
HTML
<div id="gallery">
<div id="images">
<div class="container">
<a href="images/gallery/image1.jpg" data-lightbox="mygallery">
<img src="images/gallery/image1.jpg">
<div class="overlay">
<img src="images/magnify.png">
</div>
</a>
</div>
<div class="container">
<a href="images/gallery/image2.jpg" data-lightbox="mygallery">
<img src="images/gallery/image2.jpg">
<div class="overlay">
<img src="images/magnify.png">
</div>
</a>
</div>
</div>
</div>
CSS
#gallery{
text-align: center;
}
#images{
display: inline-block;
text-align: left;
}
img{
width: 300px;
cursor: pointer;
}
.overlay {
position: absolute;
right: 0;
left: 0;
cursor: pointer;
visibility: hidden;
color: transparent;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
transition: all ease-in .3s;
}
.overlay > img{
height: 50%;
width: 50%;
top: 50%;
visibility: hidden;
left: 50%;
transform: translate(-50%,-50%);
position: absolute;
}
.overlay:hover > img{
visibility: visible;
}
.container {
position: relative;
display: inline-block;
margin: 5px;
}
.container:hover .overlay {
visibility: visible;
opacity: .6;
background: black;
color: white;
}
How about styling the image wrapper .images like
.images {
width:80%;
margin:0 auto;
text-align:left;
}
this works
body{
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-content: center;
align-items: center;
}
section{
height:400px;
width:400px;
background:grey;
}
img {
margin:48px;
}
<section>
<img src="https://telecomputingarchitects.com/media/logo.png" height="24"/>
<img src="https://telecomputingarchitects.com/media/logo.png" height="24"/>
<img src="https://telecomputingarchitects.com/media/logo.png" height="24"/>
<img src="https://telecomputingarchitects.com/media/logo.png" height="24"/>
<img src="https://telecomputingarchitects.com/media/logo.png" height="24"/>
</section>
Give your #gallery div a max-width, text-align: center, and margin:auto, then put your header in another div inside the #gallery, but outside the #images. Then put text-align: left on your #images div.
See example below:
#gallery {
text-align: center;
max-width: 420px;
margin: auto;
}
img {
width: 100px;
cursor: pointer;
}
.container {
display: inline-block;
}
#images {
text-align: left
}
<div id="gallery">
<div id="header">
<h1>Header</h1>
</div>
<div id="images">
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=d42">
<img src="http://thecatapi.com/api/images/get?id=d42">
</a>
</div>
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=21o">
<img src="http://thecatapi.com/api/images/get?id=21o">
</a>
</div>
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=49e">
<img src="http://thecatapi.com/api/images/get?id=49e">
</a>
</div>
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=13v">
<img src="http://thecatapi.com/api/images/get?id=13v">
</a>
</div>
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=6e6">
<img src="http://thecatapi.com/api/images/get?id=6e6">
</a>
</div>
<div class="container">
<a href="http://thecatapi.com/api/images/get?id=4bf">
<img src="http://thecatapi.com/api/images/get?id=4bf">
</a>
</div>
</div>
</div>
HTML
<h2>HEADER</h2>
<div class="container">
<img src=""/>
<img src=""/>
<img src=""/>
<img src=""/>
<img src=""/>
<img src=""/>
</div>
CSS
h2 {
text-align: center;
}
.container {
float: left;
}
img {
border: medium solid black;
width: 200px;
height: 350px;
margin: 5% 2%;
}

How To place Both Logo and text in the Same Line?

what is the HTML with CSS Code to align have logo and text in the same line...that it must look as shown in the below pattern..
HTML:
<div class="top_left">
<div class="header">
<img src="https://b.fastcompany.net/multisite_files/fastcompany/imagecache/inline-small/inline/2015/09/3050613-inline-i-2-googles-new-logo-copy.png" alt="logo"/> <br/>
</div>
<h2 id="site-title"><a>GOOGLE</a>
<div id="site-description">SEARCH ENGINE </div>
</h2>
</div>
You can use the following html/css combo:
/* CSS */
.container-div {
position: fixed;
top: 0px;
left: 0px;
width: 250px;
height: 150px;
}
.img-div {
display: inline-block;
position: relative;
width: 45%;
height: 100%;
overflow: hidden;
}
.img-div img {
position: absolute;
top: 0px;
left: 5%;
width: 90%;
height: 50%;
border: 1px solid red;
}
.img-placeholder {
position: absolute;
top: 7.5%;
left: 15%;
}
.text-div {
display: inline-block;
position: relative;
width: 50%;
height: 100%;
border: 1px solid green;
overflow: auto;
}
<!-- HTML -->
<div class="container-div">
<div class="img-div">
<img />
<p class="img-placeholder">
Image Goes Here
</p>
</div>
<div class="text-div">
<h2>
Texty-text
</h2>
<p>
Sub-texty-text
</p>
</div>
</div>
Use this code
<p><img src="https://cdn.pixabay.com/photo/2016/12/27/21/03/lone-tree-1934897_960_720.jpg" alt="imag" style="height: 50px;width: 50px;"><span>kiran</span></p>
hello try to make a container for the logo and the text and a few div with a float that would do the job if i am right
like this
<div class="name of class you made" //give jut a with>
<div class="logo" //put float in this with a with>logo</div><div class="tekst" //put float in this with a with>tekst</div>
</div>
i am not sure but this would help
You can either use (on the h4 elements, as they are block by default)
display: inline-block;
Or you can float the elements to the left/rght
float: left;
Just don't forget to clear the floats after
clear: left;
Try something like this
<div class="container">
<div id="logo">
<img src="http://placehold.it/150x100">
</div>
<div id="text">
<h2>Hello</h2>
<h3>World</h3>
</div>
</div>
CSS:
.container > div {
display: inline-block;
padding: 5px;
}
#logo, #text {
float: left;
}
Here's the fiddle

How to make a child div wider than the parent div [duplicate]

This question already has answers here:
Is there a way to make a child DIV's width wider than the parent DIV using CSS?
(15 answers)
Closed 7 years ago.
I want to make a child div whose width must wider than the parent div. As I read on some examples, It is written that the child div must have a relative position. I tried lots of combination but didn't help me. Please check below CSS and HTML codes and help me. Normally, I prepared it in jsFiddle but it is hard to understand the problem in there.
I gave an id that called thatDivMustHaveTheSameWidthWithContainer for the div that I want to make the same width with the container.
Css :
.site-container {
background-color: #000;
margin: 0 auto;
max-width: 1600px;
min-width: 1180px;
width: 100%;
position: relative;
}
.container {
display: block;
width: 1180px;
margin: 0 auto;
position: relative;
}
.slider {
display: block;
margin-bottom: 40px;
}
.slider .slider-container {
position: relative;
width: 1180px;
height: 208px;
}
.slider .slider-container .slider-content {
position: absolute;
width: 1060px;
left: 60px;
height: 208px;
overflow: hidden;
}
.slider .slider-container .slider-content .slider-content-wrapper {
width: 1080px;
height: 208px;
}
.slider .slider-container .slider-content .slider-content-wrapper .slider-item {
width: 158px;
height: 206px;
border: 1px solid #333;
float: left;
display: block;
margin-right: 20px;
}
.product-item {
position: relative;
overflow: hidden;
width: 158px;
height: 206px;
border: 1px solid #333;
float: left;
display: block;
margin-right: 20px;
}
.product-item img {
width: 158px;
height: 206px;
}
HTML:
<body>
<div class="site-container">
<div style="min-height: 700px;">
<div class="container">
<div class="slider">
<div class="slider-container">
<div class="slider-content">
<div class="slider-content-wrapper">
<a href="#" class="slider-item product-item">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRu0ngHBYiMliunAqW5pJ4f-KuiWapDqBJkb3aIpz33a506cpOg0A" alt="">
</a>
<a href="#" class="slider-item product-item">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRu0ngHBYiMliunAqW5pJ4f-KuiWapDqBJkb3aIpz33a506cpOg0A">
</a>
<a href="#" class="slider-item product-item">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRu0ngHBYiMliunAqW5pJ4f-KuiWapDqBJkb3aIpz33a506cpOg0A">
</a>
</div>
</div>
</div>
</div>
<div class="slider" style="background-color: red;" id="thatDivMustHaveTheSameWidthWithContainer">
<div class="slider-container">
<div class="slider-content">
<div class="slider-content-wrapper">
<a href="#" class="slider-item product-item">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRu0ngHBYiMliunAqW5pJ4f-KuiWapDqBJkb3aIpz33a506cpOg0A" alt="">
</a>
<a href="#" class="slider-item product-item">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRu0ngHBYiMliunAqW5pJ4f-KuiWapDqBJkb3aIpz33a506cpOg0A">
</a>
<a href="#" class="slider-item product-item">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRu0ngHBYiMliunAqW5pJ4f-KuiWapDqBJkb3aIpz33a506cpOg0A">
</a>
</div>
</div>
</div>
</div>
<div class="slider">
<div class="slider-container">
<div class="slider-content">
<div class="slider-content-wrapper">
<a href="#" class="slider-item product-item">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRu0ngHBYiMliunAqW5pJ4f-KuiWapDqBJkb3aIpz33a506cpOg0A">
</a>
<a href="#" class="slider-item product-item">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRu0ngHBYiMliunAqW5pJ4f-KuiWapDqBJkb3aIpz33a506cpOg0A" alt="">
</a>
<a href="#" class="slider-item product-item">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRu0ngHBYiMliunAqW5pJ4f-KuiWapDqBJkb3aIpz33a506cpOg0A">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
actually, i can't understand what you really want to do, but i have created a fiddle for you Check This On JsFiddle and i want it helps you ... let me know if it doesn't :)
.parent {
background-color: orange;
margin:50px;
width: 200px;
position: relative;
min-height: 200px;
}
.child {
position: absolute;
top: 20px;
bottom: 20px;
left: -30px;
right:-30px;
background-color: green;
}
<div class="parent">
<div class="child"></div>
</div>

Mobile Safari: Image with 100% height not visible in absolute positioned container

Demo: http://codepen.io/malte/pen/kDlbt
I am using an absolute positioned wrapper to center an image in a thumbnail frame. (Only) On mobile safari, the image won't be displayed. if you inspect the .image-pos container you'll see that the height is properly set to its parent's size. applying a fixed px height to it will make the image show up... Does anyone know how to fix that?
It's working on any Desktop browser...
HTML:
<div class="wrapper">
<div class="thumb-grid">
<div class="thumb">
<a href="#" class="image">
<div class="image-pos">
<img src="http://images.weserv.nl/?url=static.living.is/gallery/original/5184f3631034bcdf16bd4d37c341928e.jpg&il&w=600" />
</div>
</a>
<div class="details">
<h5>Image Title</h5>
</div>
</div>
<div class="thumb">
<a href="#" class="image">
<div class="image-pos">
<img src="http://images.weserv.nl/?url=static.living.is/gallery/original/5184f3631034bcdf16bd4d37c341928e.jpg&il&w=600" />
</div>
</a>
<div class="details">
<h5>Image Title</h5>
</div>
</div>
<div class="thumb">
<a href="#" class="image">
<div class="image-pos">
<img src="http://images.weserv.nl/?url=static.living.is/gallery/original/016e551de2f53d58e7f4acd68279e6a1.JPG&il&w=600" />
</div>
</a>
<div class="details">
<h5>Image Title</h5>
</div>
</div>
</div>
</div>
CSS:
.wrapper {
width: 600px;
margin: 30px auto 0
}
.thumb-grid {
text-align: justify;
}
.thumb-grid:after {
content: '';
display: inline-block;
width: 100%;
}
.thumb {
position: relative;
display: inline-block;
width: 31.5%;
height: 0;
padding-top: 29%;
margin-bottom: 6%;
}
.image {
height: 73%;
overflow: hidden;
position: absolute;
text-align: center;
top: 0;
width: 100%;
vertical-align: top;
display: block;
border: 1px solid #eee;
}
.image-pos {
height: 100%;
left: 50%;
margin-left: -300px;
position: absolute;
text-align: center;
width: 600px;
}
.image-pos img {
height: 100%;
max-height: 100%;
min-height: 100%;
max-width: none;
width: auto;
display: inline;
border: 0;
}
.details {
height: 27%;
position: absolute;
top: 73%;
}
.details h5 {
margin: 0;
padding-top: 5px;
}
Demo: http://codepen.io/malte/pen/kDlbt