I am having trouble getting my image to rotate. I have tried using the image rotate property in CSS but that doesn't seem to have don the trick. The elements above the image are floated elements. I'm not sure if they might be interfering with the image in some way.
body {
margin: 0;
}
h1,
h2 {
text-align: center;
}
#wrapper {
background: #eee;
max-width: 60%;
margin: 0 auto;
overflow: auto;
}
.float {
align-content: center;
margin: 2.5%;
max-width: 20%;
float: left;
text-align: center;
background-color: #eee;
}
img {
display: block;
margin: 0 auto;
clear: both;
max-width: 70%;
image-orientation: 90deg;
}
<h1>Postioning Practice</h1>
<h2>Using Floated Elements</h2>
<div id="wrapper">
<div class="float">
<h3>Position 1</h3>
<p></p>
</div>
<div class="float">
<h3>Position 2</h3>
<p>.</p>
</div>
<div class="float">
<h3>Position 3</h3>
<p></p>
</div>
<div class="float">
<h3>Position 4</h3>
<p>.</p>
</div>
<a href="yingCake.jpeg">
<img src="yingCake.jpeg" alt="Image of Ying eating cake">
</a>
</div>
The credit should go to #zsawaf, but to answer this question. Indicated in the comments image-orientation is only for firefox browsers.
Instead in your css file use:
transform: rotate(90deg);
You need to use "transform: rotate()" instead of image-orientation;
So the css for your image should look like this;
img {
display: block;
margin: 0 auto;
clear: both;
max-width: 70%;
transform: rotate(90deg);
}
<h1>Postioning Practice</h1>
<h2>Using Floated Elements</h2>
<div id="wrapper">
<a href="yingCake.jpeg">
<img src="yingCake.jpeg" alt="Image of Ying eating cake">
</a>
</div>
image-orientation is an experimental feature with limited browser support.
Related
I'm working in Wordpress and i need to insert 3 image in a row.
I'm using default editor because of my client ask that.
Insert the 3 image html for the page and then give this a little CSS with simple CSS plugin :
It's okay, the 3 image appear in a row, which has 170px height, but when i open this in mobile or tablet the scale isn't responsive.
I try to make container which has 170px height, and put the image them but wasn't working. I try to make #media query but that wasn't work.
Anyone can help me ?
I want if these 3 picture is got ca. 170px and being responsive.
* {
box-sizing: border-box;
}
.tanfolyam-kepek {
float: left;
width: 33.33%;
padding: 10px;
height: 170px;
}
.clearfix::after {
content: "";
clear: both;
display: table;
}
<div class="clearfix">
<div class="box">
<img class="tanfolyam-kepek" src="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc1-226x300.jpg" alt=""/>
</div>
<div class="box">
<img class="tanfolyam-kepek" src="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc2-300x300.jpg" alt=""/>
</div>
<div class="box">
<img class="tanfolyam-kepek"src="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc3-300x243.jpg" alt=""/>
</div>
</div>
Responsive images on a row. Verttical and horizontal alignment. No use of clearfix. Cross browser.
<div class="box-container">
<div class="box">
<a href="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc1.jpg">
<img class="tanfolyam-kepek" src="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc1-226x300.jpg" alt=""/>
</a>
</div>
<div class="box">
<a href="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc2.jpg">
<img class="tanfolyam-kepek" src="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc2-300x300.jpg" alt=""/>
</a>
</div>
<div class="box">
<a href="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc3.jpg">
<img class="tanfolyam-kepek"src="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc3-300x243.jpg" alt=""/>
</a>
</div>
</div>
with css
* {
box-sizing: border-box;
}
.box-container {
height: 170px; /* height you asked for */
outline: thin dotted grey; /* this outline for test only */
}
#media (max-width: 575.9px) {
.box-container {
height: ...px; /* for mobile, for example 140px */
}
}
.box {
float: left;
width: 33.333%;
height: 100%;
text-align: center; /* horizontal alignment */
}
.box a {
display: block;
/* 5 lines below for vertical alignment */
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.box img {
max-width: 100%;
height: auto; /* responsive image */
max-height: 170px; /* no overflow */
border: 10px solid #fff; /* border used as padding */
}
you can use bootstrap grid to make your images responsive. all you have to do is
<div class="row">
<div class="col-sm-4 col-xs-4>
//your image here
</div>
<div class="col-sm-4 col-xs-4>
//your image here
</div>
<div class="col-sm-4 col-xs-4>
//your image here
</div>
</div>
And avoid using px to specify the size since it is not responsive. Use vh and vw which stand for viewport height and viewport width respectively
.box{
display: inline-block;
width: 31.3%;
height: 200px;
text-align: center;
border: 1px solid #ddd;
padding: 20px 0;
margin: 10px;
}
.box img{
vertical-align: middle;
display: inline-block;
height: 100%;
max-width: none;
width: auto;
}
You can have something like this for have always tree picters in a row.
* {
box-sizing: border-box;
}
.tanfolyam-kepek {
float: left;
width: 33.33%;
padding: 10px;
height: 170px;
object-fit: cover;
}
.clearfix::after {
content: "";
clear: both;
display: table;
}
<div class="clearfix">
<div class="box">
<img class="tanfolyam-kepek" src="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc1-226x300.jpg" alt=""/>
</div>
<div class="box">
<img class="tanfolyam-kepek" src="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc2-300x300.jpg" alt=""/>
</div>
<div class="box">
<img class="tanfolyam-kepek"src="https://ezoakademia.hu/wp-content/uploads/2018/12/rozsakvarc3-300x243.jpg" alt=""/>
</div>
</div>
I am struggling with creation of a collection of elements wrapped inside a single one. I made a sketch of what i was trying to create.
The HTML would look like this:
<div class="wrapper-1">
<div class="image"></div>
<h3 class="title">HEY NOW</h3>
<p class="text">you a rock star, hey now! You are a rock star</p>
</div>
What would be the best way to create such a wrapper?
I would prefer to create two columns as .left-side and .right-side inside the main wrapper and add the contents to the these columns as following:
<div class="wrapper-1">
<div class="left-side">
<div class="image"></div>
</div>
<div class="right-side">
<h3 class="title">HEY NOW</h3>
<p class="text">you a rock star, hey now! You are a rock star</p>
</div>
</div>
Here is the fully implemented version:
.wrapper-1 {
width: 400px;
height: 100px;
}
.left-side {
float: left;
width: 100px;
height: 100px;
margin-right: 15px;
}
.left-side > .image {
background: url(http://placehold.it/100x100) no-repeat center center;
width: 100px;
height: 100px;
margin-right: 10px;
}
.right-side {
float: left;
width: 285px;
height: 100px;
}
.right-side > .title {
margin: 0;
}
<div class="wrapper-1">
<div class="left-side">
<div class="image"></div>
<img src="" alt="">
</div>
<div class="right-side">
<h3 class="title">HEY NOW</h3>
<p class="text">you a rock star, hey now! You are a rock star</p>
</div>
</div>
How about this, using flexbox
.wrapper-1 {
display: flex;
}
.wrapper-2 {
display: flex;
flex-direction: column
}
.wrapper-1 .image {
width: 100px;
height: 100px;
background: url(http://placehold.it/100/00f);
margin-right: 10px;
}
<div class="wrapper-1">
<div class="image"></div>
<div class="wrapper-2">
<h3 class="title">HEY NOW</h3>
<p class="text">you a rock star, hey now! You are a rock star</p>
</div>
</div>
And if you can't change markup, use position: absolute
.wrapper-1 {
padding-left: 110px;
box-sizing: border-box;
}
.wrapper-1 .image {
position: absolute;
left: 0;
top: 0;
width: 100px;
height: 100px;
background: url(http://placehold.it/100/00f);
}
<div class="wrapper-1">
<div class="image"></div>
<h3 class="title">HEY NOW</h3>
<p class="text">you a rock star, hey now! You are a rock star</p>
</div>
Here is a complete solution:
HTML:
<div class="wrapper clearfix">
<div class="left">
<img src="img.png">
</div>
<div class="right">
<h3>text</h3>
<p>text text</p>
</div>
</div>
CSS:
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
* html .clearfix { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */
.wrapper {
box-sizing: border-box; /* makes padding go on the inside */
padding: 10px; /* gives interior padding */
width: 1170px; /* whatever width you want the container to be */
margin: 0 auto; /* center it */
background-color: #fff;
}
.left {
width: 20%; /* whatever width you want the left side to be, stick to percentages */
float: left;
}
.left img {
width: 100%;
height: auto;
}
.right {
width: 77%; /* whatever width you want the right side to be, stick to percentages, notice that 77% and 20% dont add up to 100%, this is to account for the small gap inbetween the divs */
float: right;
}
Note: "clearfix" is used when floating things left and right. It prevents the common error where the div collapses in itself when child divs are being floated.
working jsfiddle: here
I need a set of icons grouped under a div to appear to the right of my logo (which is located on the top-left corner). I need the logo and all icons to have a position of relative. I am using float:left for both divs, but the second div (the group of icons) appears below the logo and not to its right. I have also tried grouping them under an unordered list and input style="float:left" as HTML, but it does not work either.
Here is the CSS:
div.container {
width: 1111px;
}
#parent {
display: flex;
}
.logo {
float: left;
position: relative;
top: 0px;
margin-left: 0px;
}
#icons {
position: relative;
float: left;
white-space: nowrap;
width: 100%;
display: table;
max-width: 100%;
}
.all-icons {
position: relative;
float: left;
vertical-align: middle;
padding: 15px;
display: table-cell;
}
.all-icons img {
height: auto;
width: auto;
max-height: 77px;
max-width: 100%;
margin: 15px;
}
<body>
<div class="container">
<div id="parent">
<div class="logo"> <img src="http://placehold.it/77" width="27%" height="27%"> </div>
<div id="icons" style="float:left" class="all-icons">
<img src="http://placehold.it/77" width="389" height="317">
<img src="http://placehold.it/77" width="451" height="317">
<img src="http://placehold.it/77" width="427" height="317">
<img src="http://placehold.it/77" width="837" height="317">
<img src="http://placehold.it/77" width="594" height="317">
</div>
</div>
</div>
</body>
Is this what you look for?
div.container {
/* width: 1111px; */
}
#parent {
display: flex;
}
.logo img {
margin: 15px;
}
.all-icons {
white-space: nowrap;
}
.all-icons img {
margin: 15px;
}
<div class="container">
<div id="parent">
<div class="logo">
<img src="http://placehold.it/77/f00" alt="">
</div>
<div id="icons" class="all-icons">
<img src="http://placehold.it/77" alt="">
<img src="http://placehold.it/77" alt="">
<img src="http://placehold.it/77" alt="">
<img src="http://placehold.it/77" alt="">
<img src="http://placehold.it/77" alt="">
</div>
</div>
</div>
If you can't use flex, try display: table
div.container {
/* width: 1111px; */
}
#parent {
display: table;
}
.logo {
display: table-cell;
}
.all-icons {
display: table-cell;
}
.logo img {
margin: 15px;
}
.all-icons {
white-space: nowrap;
}
.all-icons img {
margin: 15px;
}
<div class="container">
<div id="parent">
<div class="logo">
<img src="http://placehold.it/77/f00" alt="">
</div>
<div id="icons" class="all-icons">
<img src="http://placehold.it/77" alt="">
<img src="http://placehold.it/77" alt="">
<img src="http://placehold.it/77" alt="">
<img src="http://placehold.it/77" alt="">
<img src="http://placehold.it/77" alt="">
</div>
</div>
</div>
Add #icons { text-align: right; }, i think this will help you.
please do remove #parent { display: flex;} and also remove #icons { width: 100% }
It looks in line to me (see below image) however the margins/padding make it look like it's below and to the right.
Other things which may prove useful having seen your code:
display: inline-table
http://flexboxgrid.com/
remembering to keep CSS files as small as possible, not as comprehensive as possible to make it easy to find and fix things
Your image of logo class not in center of its parent. Add
text-align: center;
margin: auto;
into you .logo class
How do I vertically center an img and an h1 in a div? Right now I have a png and an h1 in a header but the content is automatically in the top left. How do I put it in the middle and keep it responsive? Here's my HTML:
header {
text-align: center;
max-height:680px;
}
<header>
<h1 id="title">Lorem Ipsum</h1>
<img id="arrows" src="images/arrows.png">
<h3 id="sub-title">Lorem ipsum</h3>
</header>
edit: Sorry I should have mentioned that the header has a specific height. How do I put the text and image right in the middle of the header, both vertically and horizontally?
I know two ways to align it vertically.
First way: using table
header {
text-align: center;
display: table-cell;
vertical-align: middle;
}
.wrapper {
display: table;
position: absolute;
height: 100%;
width: 100%;
}
<div class="wrapper">
<header>
<h1 id="title">Lorem Ipsum</h1>
<img id="arrows" src="images/arrows.png">
<h3 id="sub-title">Lorem ipsum</h3>
</header>
</div>
Second way: using relative position
body, html {
height: 100%;
}
div.wrapper {
height: 100%;
}
header {
text-align: center;
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
<div class="wrapper">
<header>
<h1 id="title">Lorem Ipsum</h1>
<img id="arrows" src="images/arrows.png">
<h3 id="sub-title">Lorem ipsum</h3>
</header>
</div>
If you want them in a line and centered:
header{
text-align: center;
}
h1, h3, img{
display: inline-block;
margin: 0 10px;
}
Centering it horizontally and vertically using Flexbox.
html,
body {
height: 100%;
}
.flex-wrap {
display: flex;
justify-content: center;
height: 100%;
}
header {
align-self: center;
}
<div class="flex-wrap">
<header>
<h1 id="title">Lorem Ipsum</h1>
<img id="arrows" src="http://placehold.it/300x300">
<h3 id="sub-title">Lorem ipsum</h3>
</header>
</div>
I'm trying to make a horizontally scrolling div with various other divs inside of it.
<div class="slider">
<div class="item">
<div class="info">
<h1>Title</h1>
</div>
</div>
<div class="item">
<div class="info">
<h1>This is a really long title</h1>
</div>
</div>
<div class="item">
<div class="info">
<h1>Title</h1>
</div>
</div>
</div>
.slider {
white-space: nowrap;
overflow: auto;
}
.item {
display: inline-block;
position: relative;
width: 200px;
height: 150px;
margin: 10px;
background: grey;
}
.info {
position: relative;
height: 100%;
color: #fff;
white-space: normal;
}
The problem I have is that each div has a title, and when it has white-space: normal set and the title is multiple lines, it throws off the alignment of the other divs.
Here is an example of the problem in action: http://jsfiddle.net/ur16gj3m/
Is there a way to get around this? If I change .info to position: absolute, it works. I'd prefer to not use absolute positioning though.
The problem is caused by the default vertical-align: baseline property on inline elements. This causes the blocks to line themselves up with the baseline of the text. This is a problem when the text wraps as the baseline is pushed down.
Set vertical-align: top on .item
Working Example
.slider {
white-space: nowrap;
overflow: auto;
}
.item {
display: inline-block;
position: relative;
width: 200px;
height: 150px;
margin: 10px;
background: grey;
vertical-align: top;
}
.info {
position: relative;
height: 100%;
color: #fff;
white-space: normal;
}
<div class="slider">
<div class="item">
<div class="info">
<h1>Title</h1>
</div>
</div>
<div class="item">
<div class="info">
<h1>This is a really long title</h1>
</div>
</div>
<div class="item">
<div class="info">
<h1>Title</h1>
</div>
</div>
</div>