I'm new to Wordpress and and currently want to add multiple images with text aligned to it on a page. I thought about doing it with a table, but not sure if this is the best solution. Ill describe what I thought how I'd do it.
1. Row 1. Cell Picture
1. Row 2. Cell Header Text + Body text for a short image description
I need to do that multiple times so I thought its the easiest way...
Now I tried to do that with the TablePress Plugin, the only problem is that I cant add a header text for each sell, and there for cant change the font explicitly for the header.
Is there an alternative to TablePress that allows me to change fonts and colors of text within a cell?
Or should I do it manually?
Really appreciate your help.
Thanks
Is this what you're looking for?
.container {
width: 100%;
}
.image, .description {
width: 50%;
float: left;
box-sizing: border-box;
}
.image img {
width: 100%;
}
.description {
padding: 15px;
}
<div class="container">
<div class="image">
<img src="https://preview.ibb.co/ioNAzT/img02.jpg">
</div>
<div class="description">
<h2>Image title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ut mollis lacus. Pellentesque euismod mauris justo. Aenean eu sagittis ex. Suspendisse potenti. Duis velit lacus, vestibulum sit amet ex sed, mattis scelerisque metus.</p>
</div>
</div>
I wouldn't use a table but a flexbox to store the products. For an example see below.
.row {
display: flex;
justify-content: space-around; /* Horizontal alignment */
}
article {
display: flex;
flex-direction: column;
align-items: center; /* Horizontal alignment */
}
<div class="row">
<article>
<div class="image"><img src="https://via.placeholder.com/100x100"></div>
<h2>Header text</h2>
<p>Detail text</p>
</article>
<article>
<div class="image"><img src="https://via.placeholder.com/100x100"></div>
<h2>Header text</h2>
<p>Detail text</p>
</article>
<article>
<div class="image"><img src="https://via.placeholder.com/100x100"></div>
<h2>Header text</h2>
<p>Detail text</p>
</article>
</div>
Related
This question already has answers here:
How can I position my div at the bottom of its container?
(25 answers)
Closed 16 days ago.
I am trying to make a listing website. I am using the Jekyll Moonwalk theme as a base and heavily adapting it to my needs.
This is my first website project, so I am figuring it out as I go. Right now, I am trying to make my HTML button elements "pin" to the bottom of their container, instead of being at the bottom of the text, so they all are in line. Right now it looks like this:
Image
The red line is roughly where I want the bottom of all the buttons to me.
I have tried ChatGPT's suggestion, but it didn't work.
<div style="position: relative;">
<button style="position: absolute; bottom: 0;">Click Me</button>
</div>
You can use display flex for the boxes to arrange them like this, justify the content using space-between will always keep the buttons at the end.
here box is your card
.box{
display: flex;
flex-direction: column;
justify-content: space-between;
width: 280px;
height: 320px;
border: 1px solid #000000;
}
<div class="box">
<div class="head">
<!--header content-->
<h1> hello</h1>
</div>
<div class="body">
<!--bodycontent-->
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec facilisis libero nec nunc consectetur, non euismod ex vestibulum. Aliquam porttitor egestas sem.
</p>
</div>
<div class"bottom">
<!--button-->
<button> Tell me more</button>
</div>
</div>
style parent div of button position:relative
syle button position: absolute; bottom:0
.container{
display:flex;
}
.box{
position:relative;
outline: 1px solid black;
height: 300px;
margin:5px;
padding:5px;
display:flex;
flex-direction: column;
align-items: center;
}
button{
position:absolute;
bottom: 10px
}
<div class="container">
<div class="box">
<div class="head">
<!--header content-->
<h1> hello</h1>
</div>
<div class="body">
<!--bodycontent-->
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec facilisis
libero nec nunc consectetur, non euismod ex vestibulum. Aliquam porttitor
egestas sem.
</p>
</div>
<div class"bottom">
<!--button-->
<button> Tell me more</button>
</div>
</div>
<div class="box">
<div class="head">
<!--header content-->
<h1> hello</h1>
</div>
<div class="body">
<!--bodycontent-->
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec facilisis
libero nec nunc consectetur, non euismod ex vestibulum. Aliquam porttitor
egestas sem.
</p>
</div>
<!--button-->
<button> Tell me more</button>
</div>
</div>
I'm trying to make it so that my aside element goes to the side of my page, next to the <p> element (I hope I'm making sense). Does anyone know how I can fix this?
Here's a photo and my code:
HTML:
<aside>
<h4>Beginner Friendly Videos</h4>
<ul class="aside">
<li>
<li>
<li>
</ul>
</aside>
CSS:
.aside {
float: right;
margin: 0, 1.5%;
position: relative;
color: black;
width: 50%;
display: block;
}
I would recommend taking a look here https://css-tricks.com/snippets/css/a-guide-to-flexbox/ into Flexbox. It will save you a lot of hassle down the road as it is MUCH better for formatting than Float.
That being said, I would recommend something along the lines of below.
HTML
<body>
<div id="wrapper">
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed pellentesque turpis. Proin blandit, augue in euismod facilisis, lacus arcu bibendum purus, ut interdum libero dui in sapien. Suspendisse convallis imperdiet urna sed consequat.</p>
</div>
<aside>
<ul>
<li>1
<li>2
<l1>3
</ul>
</aside>
</div>
</body>
CSS
#wrapper {
display: flex;
flex-direction: row;
}
aside {
[Your Styles Here, No Float];
}
The result is that the aside is to right right of your p tag. Note that p is inside of a div because it is an inline element. You didn't provide all of your code so I cant provide the exact code for you, however if you adjust the width for the nested div and aside, and implement this it should work for you!
If you want the aside on the left, just place it before the nested div.
I'm trying to align a movie poster image, description text & add to cart button on the same line. The text needs to be centered aligned and not wrap around button or image. It should look like this.
However, with my current code, it looks like this. Movie description text is not center-aligned and it wraps around the button.
This is my code. How can I modify it to fix it to look like the first image?
<div class="card-block">
<div class="pull-left"><img src="https://{{movie.image}}" alt="[Image Missing]" width="70px" /></div>
<br><span>{{movie.description}}</span>
<span>
<button class="float-right btn btn-sm btn-success" (click)="addToCart(movie)">
Add to Cart
</button></span>
</div>
There are many ways to solve your problem.
You can use flex
.container {
display: flex;
align-items: center;
}
.container .item:nth-child(2){ /*Only second item padding and center text*/
padding-left: 1em;
padding-right: 1em;
text-align: center;
}
<div class="container">
<div class="item">
<img src="https://via.placeholder.com/80x100">
</div>
<div class="item">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sagittis sagittis enim. Nulla viverra aliquam.</p>
</div>
<div class="item">
<button> Add to cart </button>
</div>
</div>
Or you can try with the new CSS-Grid, but it's not supported at all on some browsers yet
.container {
display: grid;
grid-template-columns: 1fr 4fr 1fr; /*Here you set how many columns will be and how much of the space they will take, for example there are 3 values, meaning 3 columns, the first and the last one will take 1 space of the row, and the second one will take 4 spaces*/
align-items: center;
grid-gap: 1em; /*The gap between items*/
}
.container .item:nth-child(2) {
text-align: center;
}
<div class="container">
<div class="item">
<img src="https://via.placeholder.com/80x100">
</div>
<div class="item">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sagittis sagittis enim. Nulla viverra aliquam.</p>
</div>
<div class="item">
<button> Add to cart </button>
</div>
</div>
Try to use flex instead, this is example:
.wrapper {
display: flex;
flex-direction: row;
align-items: center
}
p {
text-align:center
}
<div class="wrapper">
<img src="https://via.placeholder.com/150" />
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sit amet est vel erat rutrum tempus. Etiam auctor dapibus magna, ut auctor metus pretium sed.
</p>
<button>
Add
</button>
</div>
Hope this help.
I'm making my second test HTML file from PSD file.
In this picture you may see my issue.
Could you please guide me how to sit two images next to each other which have text below?
Also I want it be responsive.
For example in large screens, the two images sit next each other. In small screens each image in one separate line.
Thanks a bunch
first have the image and text in a box like this:
<div class="contentBox">
<img>
<h3>some title</h3>
<p>some text</p>
</div>
then float those boxes.
.contentBox{
float:left;
}
I made a quick snippet to show you how you could use it:
#boxes{
text-align:center;
}
.contentBox {
display: inline-block;
width: 200px;
border: 1px solid black;
margin: 20px;
}
.contentBox img {
width: 100%;
}
.contentBox h3 {
margin: 5px;
}
.contentBox p {
text-align: justify;
margin: 5px;
}
<div id="boxes">
<div class="contentBox">
<img src="http://via.placeholder.com/350x250">
<h3>some title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin facilisis mauris sem, in elementum tortor eleifend vel.</p>
</div>
<div class="contentBox">
<img src="http://via.placeholder.com/350x250">
<h3>some title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin facilisis mauris sem, in elementum tortor eleifend vel.</p>
</div>
</div>
I have two p tags
<p style="margin: 0; display: inline;">content1</p>
<p style="margin: 0; display: inline;" align="right">content2</p>
The Output is content1content2. My expectation is like this:
content1 content2
Can anyone help. I want one "content1" in the left p and "content2" in the right 'p'.
You can use CSS flexbox for this. Below is the minimal CSS for the requested layout:
<div style="display: flex; justify-content: space-between;">
<p style="background-color: papayawhip;">Lorem ipsum dolor sit amet.</p>
<p style="background-color: palegoldenrod;">Donec eget luctus lacus.</p>
</div>
For longer content, you can use fixed-width columns:
<div style="display: flex; justify-content: space-between;">
<p style="flex-basis: 49.5%; background-color: papayawhip;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eget luctus lacus. Cras consectetur elementum mi sed consequat.</p>
<p style="flex-basis: 49.5%; background-color: palegoldenrod;">Pellentesque aliquet condimentum augue in mattis. Praesent sagittis nisl magna, a volutpat arcu imperdiet vel. Quisque et orci sed ligula cursus luctus.</p>
<!-- 49.5% + 49.5% = 99%, remaining 1% is distributed according to justify-content -->
</div>
You could do it with floats:
<p style="margin:0;display:inline;float:left">content1</p>
<p style="margin:0;display:inline:float:right" >content2</p>
The idea of the tag <p></p> is to display a paragraph. So HTML offers you the <div></div> which is a container conecpt. So you should use Salman A's Solution, because there aren't just different tags in html for no reason. Actually you can style a paragraph with css so it is getting displayed the same as a div container, but it is not meant to be like that.
I don't want to say to you, what you have to do. I just wanna help you using the "correct" tags for the things they were made for.
What you really want is something that doesn't assume sufficent width to fit both paragraphs into one line:
* { box-sizing: border-box; }
.two { width: 30em; max-width: 100%; }
.two p { display: inline-block; max-width: 50%; }
.two p:nth-child(1) { float:left; }
.two p:nth-child(2) { float:right; }
<div class="two">
<p>This is the first paragraph of two.</p>
<p>This is the second paragraph of two.</p>
</div>
Here's another quick turnaround to achieve this:
p{
text-align: center;
}
.item p{
display: inline-block;
}
.leftContent{
text-align: left;
width: 50%;
}
.rightContent{
text-align: right;
width: 50%
}
<br>
<!--Use both P tags in the same line without space -->
<article class="item">
<p class="leftContent">Content1</p><p class="rightContent">Content2</p>
</article>
float:left, float:right.... or
width:49.9%;
display:inline;
text-align:left;
text-align:right;