Keep symbol and text on same line? - html

I've got this and it's not working
.header {
text-align: center;
background: #9f7a2b;
color: white;
}
span.nowrap {
white-space: nowrap;
}
span.title {
font-family: 'Computer Modern Serif', georgia;
font-variant: small-caps;
display: block;
text-align: center;
letter-spacing: .4em;
font-size: 2.3rem;
}
<div class="header">
<img src="./images/3d-graph-model.png" style="padding: 15px 0px 22px 0px" alt="3-d graph" class="center">
<span class="nowrap">∘<span class="title">My Title</span></span>
<p>My supercool header</p>
</div>
I want the circle symbol and the "My Title" text on the same line, but the symbol tight, not spaced at the beginning of the line. Now I get the symbol above the title line. Any ideas what I'm doing wrong?

You added display: block; property to the span.title element. As the result, the element is stretched to full available width. You can use a following code to solve your problem.
.header {
display: flex;
flex-direction: column;
align-items: center;
background: #9f7a2b;
color: white;
}
span.nowrap {
white-space: nowrap;
}
span.title {
font-family: 'Computer Modern Serif', georgia;
font-variant: small-caps;
letter-spacing: .4em;
font-size: 2.3rem;
}
<div class="header">
<img src="./images/3d-graph-model.png" style="padding: 15px 0px 22px 0px" alt="3-d graph" class="center">
<span class="nowrap">∘<span class="title">My Title</span></span>
<p>My supercool header</p>
</div>

Replace
<span class="nowrap">∘<span class="title">My Title</span></span>
by
<div class="title"><span class="symbol">∘</span>My Title</div>.
Look the following code:
.header {
text-align: center;
background: #9f7a2b;
color: white;
}
.symbol {
font-size: 1.8rem;
}
.title {
font-family: 'Computer Modern Serif', georgia;
font-variant: small-caps;
display: block;
text-align: center;
letter-spacing: .4em;
font-size: 2.3rem;
}
<div class="header">
<img src="./images/3d-graph-model.png" style="padding: 15px 0px 22px 0px" alt="3-d graph" class="center">
<div class="title"><span class="symbol">∘</span>My Title</div>
<p>My supercool header</p>
</div>

You can fix your problem using display: flex; and align-items: center; Then the content will show inline... here are my code check it hope it will help you :)
.header {
text-align: center;
background: #9f7a2b;
color: white;
}
span.nowrap {
white-space: nowrap;
display: flex;
justify-content: center;
align-items: center;
}
span.title {
font-family: 'Computer Modern Serif', georgia;
font-variant: small-caps;
display: block;
text-align: center;
letter-spacing: .4em;
font-size: 2.3rem;
}
<div class="header">
<img src="./images/3d-graph-model.png" style="padding: 15px 0px 22px 0px" alt="3-d graph" class="center">
<span class="nowrap">∘<span class="title">My Title</span></span>
<p>My supercool header</p>
</div>

Related

How to make grid div responsive and change style of it in Html Css

I have this kind of grid on my web. I want it to make responsive for mobiles and tablets. I attached the screenshot of what I have now and What I want. Thanks in Advance!
When I check this on my mobile, this happens :(
How can I make it look like this
Here is my source code
.row {
display: flex;
flex-direction: row;
justify-content: center;
}
.box {
width: 20%;
height: auto;
margin-top: 12px;
background-color: rgba(0, 0, 0, 0.5);
align-items: center;
justify-content: center;
position: relative;
text-align: center;
margin: auto;
padding: 16px;
}
.box.big {
width: 40%;
margin-top: 24px;
}
<div class="row">
<div class="box">
<p style="font-family: 'Kanit', sans-serif; color: #ffffff; font-weight: 400; margin-top: 8px; font-size: 2.15vw; ">AIRFREIGHT</p>
<p style="font-family: 'Kanit', sans-serif; color: #ffffff; font-weight: 200; font-size: 1.2vw; margin-bottom: 8px;">CHINA & EU to CIS via GYD<br>CHARTERING IN CHINA<br>EU TO GYD & SCO</p>
</div>
<div class="box">
<p style="font-family: 'Kanit', sans-serif; color: #ffffff; font-weight: 400; margin-top: 8px; font-size: 2.15vw;">SEA FREIGHT</p>
<p style="font-family: 'Kanit', sans-serif; color: #ffffff; font-weight: 200; font-size: 1.2vw; margin-bottom: 8px;">SEA FREIGHT SERVICES VIA<br>POTI PORT, GE TO ASIA, EU<br>AND AMERICAS</p>
</div>
<div class="box">
<p style="font-family: 'Kanit', sans-serif; color: #ffffff; font-weight: 400; margin-top: 8px; font-size: 2.15vw;">ROAD FREIGHT
</p>
<p style="font-family: 'Kanit', sans-serif; color: #ffffff; font-weight: 200; font-size: 1.2vw; margin-bottom: 8px;">EU TO CIS VIA SOUTHERN<br>CORRIDOR<br>LTL SERVICES FROM EU</p>
</div>
<div class="box">
<p style="font-family: 'Kanit', sans-serif; color: #ffffff; font-weight: 400; margin-top: 8px; font-size: 2.15vw;">RAIL FREIGHT</p>
<p style="font-family: 'Kanit', sans-serif; color: #ffffff; font-weight: 200; font-size: 1.2vw; margin-bottom: 8px;">RAIL FREIGHT BETWEEN<br>AZE TO CIS AND POTI PORT<br>TERMINAL HANDLING IN AZ</p>
</div>
</div>
<div class="row">
<div class="box big">
<p style="font-family: 'Kanit', sans-serif; color: #ffffff; font-weight: 400; margin-top: 8px; font-size: 2.15vw;">VALUE ADDED SERVICES</p>
<p style="font-family: 'Kanit', sans-serif; color: #ffffff; font-weight: 200; font-size: 1.2vw; margin-bottom: 8px;">LTL SERVICES TO CIS<br>RORO / BREAKBULK SERVICES IN CASPIAN<br>VESSEL AGENCY SERVICES<br>CUSTOMS CLEARANCE AND TRANSIT FORMALITIES<br>APPLYING SPECIAL PERMITS & FEASIBILITY STUDY</p>
</div>
</div>
I experimented and got the answer. All i had to do is add some css code. This will help alot)
#media (max-width: 600px) {
.logo{
margin-top: 0;
height: 48px;
}
.row{
margin-top: 80px;
display: flex;
flex-direction: column;
}
.box {
margin:12px;
width: 90%;
padding: 16px;
}
.box.big{
width: 90%;
padding: 16px;
}
.boxTextHeader{
font-size: 5vw;
}
.boxTextDescription{
font-size: 3vw;
}
}
I've changed some html too by adding classes to make it more customizeable. This css is enough to get and idea.

Aligning text in a flexbox

We were asked to design and code a website for high school lesson.
I've designed it in figma and then started coding (more like suffering ahahha) in replit.
I designed both the header and the main text to be at the same level in figma., but when i started writing the code, the paragraph text is slightly shifted to the left comparing with the header.
I've tried to align them using align items and margings and stuff like that, though i dont fully understand how they work yet tbh.
If anyone knows what to do, and is willing to spend a little of their time looking into the code,
i will be very thankful!!!!!!!!!
This is a non-comercial high school homework task.
if you need more details about the project, just ask :)
the css code:
.logo2{
padding-left: 65%;}
h2{
display: flex;
font-family: 'Annie Use Your Telescope', cursive;
font-style: normal;
font-weight: normal;
text-align: center;
font-size: 63px;
color: #000000;
text-shadow: 4px 2px 0.5px #b4deb3, 0 0 1em #b4deb3;
}
.container2 { display: flex; flex-direction: column; padding: 8%;
}
.container2 div{
border: 1px solid greenyellow; padding: 10px;
}
.image1{display: flex; flex-direction: row; }
.imag1, .text1 {flex:50%;}
.imag1, .imag2, .imag3 {display: flex; justify-content: center; align-items: center;}
.image2 { display: flex; flex-direction: row;}
.imag2, .text2 {flex:50%}
.image3 { display: flex; flex-direction:row;}
.imag3, .text3 {flex:50%}
.text1, .text2, .text3 {text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25); display: flex; align-items: left; justify-content: left; text-align: left; flex-direction: column;}
.but1 {text-align: center; line-height: 1em }
.gs {
font-family: Athiti;
font-style: normal;
font-weight: normal;
font-size: 40px;
line-height: 160.5%;
}
.onedayticket {
padding-left: 15%;
font-family: Athiti;
font-style: normal;
font-weight: normal;
font-size: 28px;
line-height: 160.5%;
align-items: left;
color: #000000;
text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);}
.but1 {filter: drop-shadow(8px 9px 14px rgba(254, 193, 233, 0.71)); width: 286.79px;
height: 70px;
left: 1026px;
top: 2496px;
background: rgba(255, 255, 255, 0.68);
border: 0.5px solid #000000;
box-sizing: border-box;
box-shadow: 0px 4px 4px #B4DEB3;
font-family: Athiti;
font-style: normal;
font-weight: normal;
font-size: 28px;
line-height: 45px;
display: flex;
align-items: center;
text-align: center;
color: #000000;}
the html code:
<section class="third" id="shop">
<div class = "container">
<div class ="container2">
<div class="image1">
<div class="imag1">
<img class= "tickets" src="tck/green.png">
</div>
<div class="text1">
<header class="gs"> Green submarine </header>
<p class="onedayticket"> The one-day ticket. Lets you expore our music festival for a single day of you choice</p>
<button class="but1"> Buy ticket </button>
</div>
</div>
<div class="image2">
<div class="imag2">
<img class= "tickets2" src="tck/blue.png">
</div>
<div class="text2">
<header1 class="gs"> The Eggman </header1>
<p class="onedayticket"> The three-day ticket. Enjoy any three days of the festival with this ticket</p>
<button class="but1"> Buy ticket </button>
</div>
</div>
<div class="image3">
<div class="imag3">
<img class= "tickets3" src="tck/pink.png">
</div>
<div class="text3">
<header1 class="gs"> The Walrus </header1>
<p class="onedayticket"> Expanded VIP ticket.
During our week-long festival all the concerts are open for you at any time. </p>
<button class="but1"> Buy ticket </button>
</div>
</div>
</div>
</div>
</section>
I'm not sure if this is what you're looking for. Remove padding-left: 15%; on onedayticket because this is pushing the text to the right.

Insert a div inside an anchor removing the anchor styling in the div elements

I'm trying to make the whole div clickable, but removing any styling that the anchor adds to the div. I cannot use JS for this.
HTML code
<a href="https://stackoverflow.com" target="_blank">
<div class="style1">
<div class="style2">
<div class="style3_">
<div>
<div class="text1">
Here is the Text 1
</div>
<span class="text2">
Here is the text 2
</span>
</div>
<a href="https://stackoverflow.com" target="_blank">
Link
</a>
</div>
</div>
</div>
</a>
CSS code:
.style1 {
padding: 16px;
}
.style2 {
border-radius: 8px;
background-color: #fff;
border: 1px solid #dadce0;
box-shadow: none
}
.style3 {
display: flex;
padding: 16px;
justify-content: space-between;
align-items: center;
}
.text1 {
line-height: 1.5rem;
font-size: 1rem;
letter-spacing: .00625rem;
font-weight: 500;
}
.text2 {
line-height: 1rem;
font-size: .75rem;
letter-spacing: .025rem;
font-weight: 400;
}
a tags usually adds an underline to indicate that it is a link, that's actually just a text decoration, to remove that you can add text-decoration: none; to whatever class you want the style to be removed, or you can add that to the anchor tag directly. See the snippet below for your reference:
.style3 {
display: flex;
align-items: center;
justify-content: space-between;
border-radius: 8px;
background-color: #fff;
border: 1px solid #dadce0;
box-shadow: none;
padding: 16px;
width: max-content;
gap: 2rem;
}
.text1 {
line-height: 1.5rem;
font-size: 1rem;
letter-spacing: .00625rem;
font-weight: 500;
}
.text2 {
line-height: 1rem;
font-size: .75rem;
letter-spacing: .025rem;
font-weight: 400;
}
a{
text-decoration: none;
color: black;
flex: 1;
height: 100%;
}
<a href="https://stackoverflow.com" target="_blank">
<div class="style3">
<div>
<div class="text1">
Here is the Text 1
</div>
<span class="text2">
Here is the text 2
</span>
</div>
<div>
Link
</div>
</div>
</a>

Vertical Aligning CSS Grid Items

I am making my site's header mobile friendly using CSS grid. I searched for a way to align one of my columns vertically to the middle. This post answered that by making the column display: flex, but introduced a problem where when I hover over the link inside of the box, the box resizes and moves the text inside.
My Code:
h1 {
color: white;
font-family: garamond;
font-size: 3vw;
width: 90%;
line-height: 5%;
}
header {
background-color: darkred;
position: relative;
padding: 1px;
padding-bottom: 1em;
}
.Logo-Master {
width: 15vw;
margin: 1em;
}
header h1 {
color: white;
}
#newsCenter {
text-align: center;
font-size: 1vw;
color: white;
text-decoration: none;
}
#newsCenter p a {
color: white;
font-size: .9vw;
font-weight: normal;
}
#newsCenter p a:hover {
font-weight: bold;
}
.newsCenterValues {
font-size: 1em;
}
<header style="display: grid; grid-template-rows: auto auto;">
<div style="display: inline-grid; grid-template-columns: 1fr 4fr 1fr">
<img class="Logo-Master" src="https://static.nationalgeographic.co.uk/files/styles/image_3200/public/01-lion-populations-nationalgeographic_1777804.jpg?w=1600&h=900" alt="This is an image">
<div>
<h1>Title Title Title Title Title Title Title Title</h1>
</div>
<div style="display: flex; align-items: center;"><div id="newsCenter">
<p style="font-size: 1.2rem; font-weight: bold; color: white; line-height: 0;">Flex</p>
<p class="newsCenterValues" style="line-height: 0;">The Long Link that in this section</p>
</div></div>
</div>
</header>
The text within the flex column is supposed to be text-align: center; but it is not behaving like that. How can I fix this with it still becoming bold when I hover over it?
h1 {
color: white;
font-family: garamond;
font-size: 3vw;
width: 90%;
line-height: 5%;
}
header {
background-color: darkred;
position: relative;
padding: 1px;
padding-bottom: 1em;
}
.Logo-Master {
width: 15vw;
margin: 1em;
}
header h1 {
color: white;
}
#newsCenter {
text-align: center;
font-size: 1vw;
color: white;
text-decoration: none;
}
#newsCenter p a {
color: white;
font-size: .9vw;
font-weight: normal;
}
#newsCenter p a:hover {
font-weight: bold;
}
.newsCenterValues {
font-size: 1em;
}
<header style="display: grid; grid-template-rows: auto auto;">
<div style="display: inline-grid; grid-template-columns: 1fr 4fr 1fr">
<img class="Logo-Master" src="https://static.nationalgeographic.co.uk/files/styles/image_3200/public/01-lion-populations-nationalgeographic_1777804.jpg?w=1600&h=900" alt="This is an image">
<div>
<h1>Title Title Title Title Title Title Title Title</h1>
</div>
<div style="display: flex; align-items: center;justify-content: center;"><div id="newsCenter">
<p style="font-size: 1.2rem; font-weight: bold; color: white; line-height: 0;">Flex</p>
<p class="newsCenterValues" style="line-height: 0;">The Long Link that in this section</p>
</div></div>
</div>
</header>
This will not shift the content. In this example, I used transform: scale().
h1 {
color: white;
font-family: garamond;
font-size: 3vw;
width: 90%;
line-height: 5%;
}
header {
background-color: darkred;
position: relative;
padding: 1px;
padding-bottom: 1em;
}
.Logo-Master {
width: 15vw;
margin: 1em;
}
header h1 {
color: white;
}
#newsCenter {
text-align: center;
font-size: 1vw;
color: white;
text-decoration: none;
transition: .2s;
}
#newsCenter p a {
color: white;
font-size: .9vw;
font-weight: normal;
}
#newsCenter:hover {
transform: scale(1.1);
}
.newsCenterValues {
font-size: 1em;
}
<header style="display: grid; grid-template-rows: auto auto;">
<div style="display: inline-grid; grid-template-columns: 1fr 4fr 1fr">
<img class="Logo-Master" src="https://static.nationalgeographic.co.uk/files/styles/image_3200/public/01-lion-populations-nationalgeographic_1777804.jpg?w=1600&h=900" alt="This is an image">
<div>
<h1>Title Title Title Title Title Title Title Title</h1>
</div>
<div style="display: flex; align-items: center;"><div id="newsCenter">
<p style="font-size: 1.2rem; font-weight: bold; color: white; line-height: 0;">Flex</p>
<p class="newsCenterValues" style="line-height: 0;">The Long Link that in this section</p>
</div></div>
</div>
</header>

How to make card responsive using flexbox?

I have section which contain botstrap 4 card div and pararagraph , I want to be resposnsive,
Here is HTML:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<div class="marketing-main-page-content_details">
<div class="marketing-main-page-content_details-card">
<div class="marketing-main-page-content_card card " data-related="details2" id="card2">
<p>Która jest własciawa osoba</p>
</div>
</div>
<div class="marketing-main-page-content_description-right" id="details1">
<div class="title-right">
<p>Która 1 jest własciawa osoba</p>
</div>
<p>To ten kurs jest dla Ciebie, specjalnie dla Ciebie.
Potem dalsza część tekstu, która ma przekonać do
zakupu. Przekonany? No to klikamy poniżej i
lecimy do formularza zamówienia!
</p>
<div class="marketing-main-page-content_description-right_button">
<button type="button" class="marketing-main-page-content_description-right_button-primary">Dowiedz
się wiecej</button>
</div>
</div>
</div>
Here is css
.marketing-main-page-content_details {
display: flex;
justify-content: space-around;
}
.marketing-main-page-content_card {
font-size: 25px;
font-family: Roboto;
font-weight: normal;
color: #707070;
}
.marketing-main-page-content_card {
width: 536px;
height: 137px;
font-family: Roboto;
margin-top: 20px;
font-size: 25px;
text-align: center;
vertical-align: middle;
display: table-cell;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
align-items: center;
-webkit-box-shadow: 0 3px 13px #5C5C5C;
box-shadow: 0 3px 13px #5C5C5C;
}
.marketing-main-page-content_description-right {
width: 47%;
margin-top: 78px;
}
.title-right {
font-size: 35px;
font-family: Roboto;
font-weight: 500;
color: #707070;
}
.marketing-main-page-content_description-right p {
font-size: 25px;
font-family: Roboto;
margin-top: 28px;
color: #707070;
font-weight: normal;
}
.marketing-main-page-content_description-right p {
font-size: 25px;
font-family: Roboto;
margin-top: 28px;
color: #707070;
font-weight: normal;
}
.marketing-main-page-content_description-right {
width: 47%;
margin-top: 78px;
}
Here is jsfiddle: https://jsfiddle.net/Mwanitete/a5e4d7u3/25/
Iwould like it to be responsive but right now as you can see in jsfidle its not responsive,
what do I need to change in my code to make it repsonsive?
I would recommend to read "A Complete Guide to Flexbox" to understand, how Flexbox works. The display: flex; rule always applies to the container of the items you want to align. I added a min-width to your cards container to give it an equal width like the right container.
Also I removed the fixed width rules and lots of redundant code in your CSS. Always make sure, that your markup is valid. This should be a responsive working example:
.marketing-main-page-content_details {
display: flex;
justify-content: space-around;
flex-flow: row nowrap;
}
.marketing-main-page-content_details-card {
min-width: 50%;
}
.marketing-main-page-content_card {
font-size: 25px;
font-family: Roboto;
font-weight: normal;
color: #707070;
height: 137px;
font-family: Roboto;
margin: 20px;
text-align: center;
-webkit-box-shadow: 0 3px 13px #5C5C5C;
box-shadow: 0 3px 13px #5C5C5C;
}
.title-right {
font-size: 35px;
font-family: Roboto;
font-weight: 500;
color: #707070;
}
.marketing-main-page-content_description-right p {
font-size: 25px;
font-family: Roboto;
margin-top: 28px;
color: #707070;
font-weight: normal;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<div class="marketing-main-page-content_details">
<div class="marketing-main-page-content_details-card">
<div class="marketing-main-page-content_card card " data-related="details2" id="card2">
<p>Która jest własciawa osoba</p>
</div>
</div>
<div class="marketing-main-page-content_description-right" id="details1">
<div class="title-right">
<p>Która 1 jest własciawa osoba</p>
</div>
<p>To ten kurs jest dla Ciebie, specjalnie dla Ciebie. Potem dalsza część tekstu, która ma przekonać do zakupu. Przekonany? No to klikamy poniżej i lecimy do formularza zamówienia!
</p>
<div class="marketing-main-page-content_description-right_button">
<button type="button" class="marketing-main-page-content_description-right_button-primary">Dowiedz
się wiecej</button>
</div>
</div>
</div>