How can I move text to the next line? - html

I am a beginner and doing my first easy challenge, but I got stuck anyway :D
I want to move the text down, to the next line.
In particular, I want to make the text like this:
Final result
<div class="container">
<img src="/image-qr-code.png" alt="" />
<p class="main">Improve your front-end skills by building projects</p>
<p class="second">
Scan QR Code to visit front-end Mentor and take your coding skills to the next level
</p>
</div>

The p element will wrap automatically when there is a static width on the parent. This can also be done by using a static max-width on the element you want to constrain. You can also use margin to constrain the text relative to its parent. In your case, I used margin on second and main to allow the text to match the image you provided. Here is a simple demonstration:
.container {
box-shadow: 1px 1px 13px 7px rgb(200 198 198);
width: 240px;
max-width: 240px;
padding: 1em;
border-radius: 5px;
margin: auto;
}
.contain {
background-color: blue;
border-radius: 5px;
display: flex;
justify-content: center;
padding: 1em;
}
img {
max-width: 100%;
}
.main {
font-weight: bold;
text-align: center;
margin: 1em 2em;
}
.second {
text-align: center;
margin: 1em 1em;
}
<div class="container">
<div class="contain">
<img src="https://dummyimage.com/150/000/fff&text=QR+CODE" https://stackoverflow.com/questions/72034538/how-can-i-move-text-to-the-next-line# alt="" />
</div>
<p class="main">Improve your front-end skills by building projects</p>
<p class="second">
Scan QR Code to visit front-end Mentor and take your coding skills to the next level
</p>
</div>

What you can do is put them separate divs
This will put the words in another line.
If what you mean was that the text does not overflow, that would include CSS>
Here is some of the code
html,
body {
margin: 0;
padding: 0;
background-color: rgb(174, 220, 239);
}
.container {
display: grid;
place-items: center;
padding-top: 300px;
}
form {
background-color: white;
width: 270px;
padding: 20px;
padding-top: 90px;
}
<div class="container">
<form action="">
<img src="/image-qr-code.png" alt="" />
<p class="main">Improve your front-end skills by building projects</p>
<div class="second">
<p>
Scan QR Code to visit front-end Mentor and take your coding skills to the next level
</p>
</div>
</form>
</div>

Related

Html Css remove distance between two divs when lying in two rows and two cols [duplicate]

This question already has answers here:
CSS-only masonry layout
(4 answers)
Closed 2 years ago.
I have 4 divs that lay two in row and two columns. They are different height and I want it to be taken into consideration when displaying on page. I always want the lower divs to stick vertically to upper ones like in the left side.
Now the code.
app.component.html
<div id="wrapper">
<div id="content">
<div id="first-row">
<div class="col">
<br>
<a routerLink="/projects/endless-blow">Endelss Blow</a>
<br>
<a routerLink="/projects/endless-blow"><img src="assets/images/endlessblow_icon.png"></a>
<br><br>
<hr>
<br>
<div class="technology_images">
<img src="https://freeiconshop.com/wp-content/uploads/edd/android-flat.png" width="75px" height="75px">
<img src="https://cdn.iconscout.com/icon/free/png-256/java-23-225999.png">
<img src="https://inforce.rs/wp-content/uploads/2018/07/spring-boot-logo-e1530901263416.png" width="188px" height="75px">
<img src="assets/images/postgresql_icon.png" width="75px" height="75px">
</div>
</div>
<div class="col">
<br>
<a routerLink="/projects/book-library">Book Library API</a>
<br>
<a routerLink="/projects/book-library"><img src="assets/images/win_console_icon.png"></a>
<br><br>
<hr>
<br>
<div class="technology_images">
<img src="assets/images/java_icon.png">
<img src="assets/images/jetty_icon.png" width="265px" height="75px">
</div>
</div>
</div>
<div id="second-row">
<div class="col">
<br>
<a routerLink="/projects/endless-blow">Endelss Blow</a>
<br>
<a routerLink="/projects/endless-blow"><img src="assets/images/endlessblow_icon.png"></a>
<br><br>
<hr>
<br>
<div class="technology_images">
<img src="assets/images/android_icon.png" width="75px" height="75px">
<img src="assets/images/java_icon.png">
<img src="assets/images/spring_boot_icon.png" width="188px" height="75px">
<img src="assets/images/postgresql_icon.png" width="75px" height="75px">
</div>
</div>
<div class="col">
<br>
<a routerLink="/projects/book-library">Book Library API</a>
<br>
<a routerLink="/projects/book-library"><img src="assets/images/win_console_icon.png"></a>
<br><br>
<hr>
<br>
<div class="technology_images">
<img src="assets/images/java_icon.png">
<img src="assets/images/jetty_icon.png" width="265px" height="75px">
</div>
</div>
</div>
</div>
</div>
app.component.css
html, body {
margin: 0;
padding: 0;
align-items: center;
text-align: center;
}
body {
border: 3px solid green;
max-width: 600px;
margin: 0 auto;
color: #fff;
}
#wrapper {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: -1;
background: darkcyan;
}
#content {
border: 3px solid red;
box-sizing: border-box;
position: absolute;
padding: 0;
margin-left: 0;
margin-right: 0;
text-align: center;
overflow: auto;
left: 0;
right: 0;
top: 70px;
width: 100%;
}
#content a {
font-size: 25px;
}
#first-row {
margin-top: 20px;
}
.col {
border-radius: 15px;
-moz-border-radius: 15px;
display: inline-block;
width: 350px;
min-height: 350px;
border: 3px solid green;
background: rgba(150, 150, 50, 0.8);
vertical-align: top;
text-align:center;
margin: 0 40px;
/* margin-right: 100px; */
}
.col a img {
padding:0;
left:0;
right:0;
margin: 0 auto;
}
.technology_images {
text-align: left;
}
div:not(.technology_images, .col) {
min-height: 400px;
box-sizing: border-box;
width: 100%;
}
If you need code uploaded with result just take a look here
I did not see any topic that corresponds to my problem so please do not close this topic.
Thank you! :)
This is really hard to achieve with HTML/CSS, and be flexible at the same time, nearly to impossible I would say, because in the real world, you might not know what height and width your elements really are and how many there are on each column.
The only HTML/CSS solution (if this fits your case) would be to create a single row, with multiple columns in it and display all the items by column. For this one, you really need to know beforehand exactly how many elements you would have on each column.
For a flexible solutions, I would really recommend using Masonry. This library would help you achieve the result you need really fast without having to do a complicated layout, which will also be complicated to maintain in the long run when multiple items might get added.

I would like for the spacing between my horizontal scrolling images to be exactly the same, how to achieve?

My CSS:
#container {
position: center;
margin-top: 80px;
z-index: 950;
{block:IfGridTheme}margin-left: 430px;{/block:IfGridTheme}
{block:IfNotGridTheme}margin-left: 435px;{/block:IfNotGridTheme}
}
.entry {
position: justify;
font-size: 12px;
color: {color:Body Text};
font-family: roboto condensed;
letter-spacing: 1px;
{block:PermalinkPage}width: 1000px;
margin-top: 15px;{/block:PermalinkPage}
word-wrap: break-word;
margin-top: 45px;
}
#container1 {
white-space: nowrap;
border: none;
width: 100%;
margin-left: auto;
margin-right: auto;
}
#container1 > div {
background: none;
width: 100%;
height: 100%;
display: inline-block;
padding: 1% 5%;
margin-right: 176px;
}
.stretch {
width: 100%;
display: inline-block;
font-size: 0;
line-height: 0
}
and my HTML for a certain type of page:
<div id="container1">
<div>
<div class="picture_holder" style="width: 1080px;">
<div class="picture" style="width: 1080px;"><img alt="LINKTOFIRSTIMAGE" height="575" src="LINKTOFIRSTIMAGE" />
<div class="captioning">
<div class="caption"><em>CAPTION</em></div>
</div>
</div>
</div>
</div>
<div>
<div class="picture_holder" style="width: 1080px;">
<div class="picture" style="width: 1080px;"><img alt="SECONDIMAGELINKANDSOFORTH" height="575" src="SECONDIMAGELINKANDSOFORTH" />
<div class="captioning">
<div class="caption"></div>
</div>
</div>
</div>
</div>
</div>
On a given page with a sequence of images that are exactly the same height, width, and overall aspect ratio, the spacing between them is exactly the same (though a lot wider than I would like) like in 1) of this drawing:
... but in a sequence of images that have the same height but wildly varying widths, the spacing is pretty off like in 2).
I personally don't want either. How do I change my code so that, for both these types of pages and however many more pages I plan to create, that the spacing between every image is exactly the same amount of pixels across the whole board of the site? Is there an imaginary box around these images causing the issue?
edit: I should also state that I am using the HTML function on a website, Tumblr.com, so certain properties like flex never seem available.
edit2: display: grid; and similar don't appear available either. This is also at the top of the code if that helps:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Thank you for the info so far.
Your html structure:
<div id="parent_container">
<div id="card_1" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:red">
<caption>Card 1 caption</caption>
</div>
<div id="card_2" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:violet">
<caption>Card 2 caption</caption>
</div>
<div id="card_3" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:seagreen">
<caption>Card 3 caption</caption>
</div>
<div id="card_4" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:skyblue">
<caption>Card 4 caption</caption>
</div>
</div>
Your CSS structure:
#parent_container <=== setting up flex for container
{
display: flex;
flex-wrap: wrap; <=== makes sure if the cards are many then they go on next line
justify-content: space-evenly; <=== makes sure there is equal space
}
.card_properties
{
border: 1px solid rgba(0,0,0,0.2);
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
border-radius: 14px;
width:20vw;
height:200px;
padding:1em;
}
img <=== written this additional because I didn't have time to find image
{
width: 100%;
height: 120px;
border-radius: 14px
}
Working codepen example

Keeping wrapper container a certain percentage of body

I'm having a tough time keeping my content centered within a certain width on my personal website. I have tried many methods such as setting body to a fix width and my wrapper container to a percentage of that. I have attached a picture of my website here and highlighted where I want my content to be contained in the picture shown
.
I want my content of my website centered within that highlighted area, while at the same time keeping the background to be the full size of the screen.
I realize this may be a simple question for many, but I have spent all day looking for and trying out different methods to do this with no avail.
body {
background-color: #F0f0f0;
text-align: center;
margin-right: 0px;
margin-left: 0px;
}
.wrapper {
text-align: center;
}
.topSection {
height: 300px;
border: solid 5px;
}
.mainAbout {
padding-left: 50px;
padding-right: 50px;
vertical-align: middle;
}
.mainAbout h1 {
font-size: 60px;
font-family: arvo, sans-serif;
margin-bottom: 5px;
}
#leftBrace {
vertical-align: middle;
}
#rightBrace {
vertical-align: middle;
}
.projects {
height: 864px;
border: solid 5px;
margin-top: 2px;
background: #0F1217;
}
.projects h2 {
color: #e6e6e6;
font-family: arvo, sans-serif;
font-size: 50px;
}
<link href="https://fonts.googleapis.com/css?family=Arvo" rel="stylesheet">
<div class="wrapper">
<!---- Wrapper Starts Here --->
<div class="topSection" style="display:block" ;>
<!---- Name Section Starts Here --->
<div id="leftBrace" style="display: inline-block" ;>
<img src="leftbrace.png">
</div>
<div class="mainAbout" style="display: inline-block" ;>
<!--- Main Name and About me Section ---->
<h1> Benjamin Yan </h1>
<p> I am a Senior Year Computer Science student at Sacramento State <br> University, California. I strive to become a professional Web Developer. </p>
</div>
<!--- End mainAbout --->
<div id="rightBrace" style="display: inline-block" ;>
<img src="rightbrace.png">
</div>
</div>
<!--- Wrapper Ends Here --->
<div class="projects">
<h2> Projects </h2>
</div>
<div class="contact">
</div>
</div>
<!--- Wrapper Ends Here --->
<footer>
</footer>
Instead of using background you could style curly-braces using pseudo selector :before and :after, thus it works like font styling, you could use transform:translate to center your intro text container, check below codes.
#box {
width: 100%;
height: 300px;
overflow: hidden;
background: #ccc;
}
#box > .cnt {
width:50%;
text-align: center;
top: 50%;
left: 50%;
position: relative;
transform: translate(-50%, -50%);
}
#box:before {
content:"{";
font-size: 250px;
position: absolute;
top: 0;
left:10%;
}
#box:after {
content: "}";
font-size: 250px;
position: absolute;
top: 0;
right:10%;
}
<div id="box">
<div class="cnt">
<h1> Benjamin Yan </h1>
<p> I am a Senior Year Computer Science student at Sacramento State <br> University, California. I strive to become a professional Web Developer. </p>
</div>
</div>
Apply margin: 0 auto; to your content class. This will work.
You need to make sure add an inner class inside each wrapper and define your desired width. And need to apply margin: 0 auto to the inner. I added demo snippet.If u want specific wrapper full width just remove innerclass that's enough you will get full width. I hope it will help you.
.wrapper {
height: 300px;
width: 100%;
background: orange;
margin-bottom: 20px;
}
.inner {
width: 70%;
margin: 0 auto;
background: pink;
height: 100%;
}
<div class="wrapper">
<div class="inner"></div>
</div>
<div class="wrapper">
<div class="inner"></div>
</div>
<div class="wrapper">
<div class="inner"></div>
</div>
<div class="wrapper">
<div class="inner"></div>
</div>

Inline-block elements are staggering down after the first sibling div [duplicate]

This question already has answers here:
My inline-block elements are not lining up properly
(5 answers)
Closed 7 years ago.
I am running into an issue that I am unsure of the cause. I had three boxes that I want lined up in a horizontal line, which they are until I added my title and descriptions inside of the boxes. Why would adding the titles and descriptions make this staggering effect?
You can see what it is doing inside of my snippet.
#home-img-block-wording-container {
width: 100%;
height: 400px;
border: 1px solid black;
}
.home-img-wording-blocks {
width: 33%;
height: 100%;
text-align: center;
border: 1px solid black;
display: inline-block;
}
.home-img-wording-block-title {
padding-top: 20px;
font-size: 2em;
}
.home-img-wording-block-description {
padding: 25px 20px 0 20px;
font-size: 1.2em;
color: #adadad;
}
<div id="home-img-block-wording-container">
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">WEB DESIGN</div>
<div class="home-img-wording-block-description">The OD team can see your web design visions brought to life, creating a site that promotes your uniqueness through specific functionalities and features.</div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">ECOMMERCE</div>
<div class="home-img-wording-block-description">Custom built solutions catered towards you end goal.</div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">MARKETING STRATEGIES</div>
<div class="home-img-wording-block-description">MARKETING STRATEGIES</div>
</div>
</div>
The problem is that the text in each inline-block .home-img-wording-blocks element is being aligned to the baseline of the previous box.
As stated by the relevant specification:
10.8 Line height calculations: the line-height and vertical-align properties
The baseline of an inline-block is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes or if its overflow property has a computed value other than visible, in which case the baseline is the bottom margin edge.
It's worth pointing out that the default value for the vertical-align property is baseline. To fix your problem, you could align the element to the top by adding vertical-align: top:
#home-img-block-wording-container {
width: 100%;
height: 400px;
border: 1px solid black;
}
.home-img-wording-blocks {
width: 33%;
height: 100%;
text-align: center;
border: 1px solid black;
display: inline-block;
vertical-align: top;
}
.home-img-wording-block-title {
padding-top: 20px;
font-size: 2em;
}
.home-img-wording-block-description {
padding: 25px 20px 0 20px;
font-size: 1.2em;
color: #adadad;
}
<div id="home-img-block-wording-container">
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">WEB DESIGN</div>
<div class="home-img-wording-block-description">The OD team can see your web design visions brought to life, creating a site that promotes your uniqueness through specific functionalities and features.</div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">ECOMMERCE</div>
<div class="home-img-wording-block-description">Custom built solutions catered towards you end goal.</div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">MARKETING STRATEGIES</div>
<div class="home-img-wording-block-description">MARKETING STRATEGIES</div>
</div>
</div>
Just set vertical-align: top; to the .home-img-wording-blocks item
A solution by hiding the overflow of your divs and making sure no unintentional margins or padding are being applied:
* {
margin:0;
padding:0;
}
#home-img-block-wording-container {
width: 100%;
height: 400px;
border: 1px solid black;
}
.home-img-wording-blocks {
width: 33%;
height: 100%;
text-align: center;
border: 1px solid black;
display: inline-block;
overflow:hidden;
}
.home-img-wording-block-title {
padding-top: 20px;
font-size: 2em;
}
.home-img-wording-block-description {
padding: 25px 20px 0 20px;
font-size: 1.2em;
color: #adadad;
}
<div id="home-img-block-wording-container">
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">WEB DESIGN</div>
<div class="home-img-wording-block-description">The OD team can see your web design visions brought to life, creating a site that promotes your uniqueness through specific functionalities and features.</div>
</div><div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">ECOMMERCE</div>
<div class="home-img-wording-block-description">Custom built solutions catered towards you end goal.</div>
</div><div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">MARKETING STRATEGIES</div>
<div class="home-img-wording-block-description">MARKETING STRATEGIES</div>
</div>
</div>

How to build some basic tiles with Title and Description?

I want to build some basic tiles using HTML/CSS, maybe utilize jQuery UI because I already use it for other things.
I am looking for something like this, and looking for HTML/direction on how to get it inside a web browser.
Namely, look at the HTML below.
Problems with HTML mark-up
description does not float to the bottom
adding subsequent square div boxes (aka "tiles") does not position them to the right of the previous box
<div style="width:100px;height:100px;background-color:lightgrey;text-align:center">
<div style="">Module</div>
<div style="width:100px;height:20px;position:absolute">
<span style=""> description </span>
</div>
</div>
If you just want basic squares with text in them you probably want something like:
<html>
<head>
<style>
.square {
color:black;
border-style: solid;
border-width: 10px;
width: 200px;
height: 200px;
text-align: center;
}
</style>
</head>
<body>
<div class="square">
<h3>Module Name</h3>
<p>Module is used for this and that</p>
</div>
</body>
</html>
If you need to align the description to the bottom of the cell you could look at CSS vertical-align: text-bottom;
For nicely aligning blocks that will appear to the right of each other and then wrap around into a grid, I recommend using lists with inline-block. A fiddle example is here. http://jsfiddle.net/89a07gm3/2
My base result:
.square {
color: black;
border-style: solid;
border-width: 3px;
width: 250px;
height: 200px;
text-align: center;
list-style-type: none;
display: inline-block;
margin: 0px 50px 10px 20px;
position: relative;
}
.child {
position: absolute;
bottom: 0;
width: 100%;
text-align: center;
}
<div onclick="location.href='#';" style="cursor: pointer;" class="square">
<h1>Module Name</h1>
<p class="child">Module is used for this and that</p>
</div>
<div onclick="location.href='#';" style="cursor: pointer;" class="square">
<h1>Module Name</h1>
<p class="child">Module is used for this and that</p>
with credit to Beth + commenters