I have three div elements which have h1 contents. I want first div at left side, 2nd at center and the 3rd at right side, meaning all in the row. When I resize the window (responsiveness), the text should not break into two lines but it should only minimize or maximize the gap between each div. Currently, all three div are very close to each other. It is written in wordpress, but here is code snippet of that part:
<div style="display:inline-block;">
<h1 style="color: white;">Yaqoob Yawar</h1>
</div>
<div style="display:inline-block;">
<img src="https://yaqoobyawar.com/wp-content/uploads/2019/12/logo5.png" alt="Yaqoob Yawar">
</div>
<div style="display:inline-block;">
<h1 style="color: white;">یعقوب یاور</h1>
</div>
It is implemented on the url: yaqoobyawar.com
Update your existing HTML
<div class="slot-c">
<div style="display:inline-block;">
<h1 style="color: white;">Yaqoob Yawar</h1>
</div>
<div style="display:inline-block;">
<img src="https://yaqoobyawar.com/wp-content/uploads/2019/12/logo5.png" alt="Yaqoob Yawar" scale="0">
</div>
<div style="display:inline-block;">
<h1 style="color: white;">یعقوب یاور</h1>
</div>
</div>
with the this HTML which is using the Bootstrap 4 Grid.
<div class="row">
<div class="col">
<h1 style="color: white;">Yaqoob Yawar</h1>
</div>
<div class="col" style="text-align: center;">
<img src="https://yaqoobyawar.com/wp-content/uploads/2019/12/logo5.png" alt="Yaqoob Yawar" scale="0">
</div>
<div class="col">
<h1 style="color: white;">یعقوب یاور</h1>
</div>
</div>
Also, remove the d-flex class from its parent div.
.grid-container {
display: grid;
grid-template-rows: 1fr;/* No. of row You want to create */
grid-template-columns: 1fr 1fr 1fr; /*No. of column you want to create */
}
<div class="grid-container">
<div>
<h1 >Yaqoob Yawar</h1>
</div>
<div>
<img src="https://yaqoobyawar.com/wp-content/uploads/2019/12/logo5.png" alt="Yaqoob Yawar">
</div>
<div >
<h1 >یعقوب یاور</h1>
</div>
</div>
Related
I tried to align several items by using two columns and positioning the text, icon, and line within the left column and the other text on the right column, but they don't align properly. It currently looks like this but it should look like the picture attached. How can I fix this?
<div class="col-12">
<h1 class="orange">LET'S RUB IT IN</h1>
<h2>How Much?</h2>
</div>
<div class="col-6"> <!--left column-->
<div class="circle side">
<img src="./chemical#2x.png" alt="chemical" class="icon">
</div>
<h5 class="side">1 Shot Glass<br>or 1 oz.</h5>
<div class="line v side"></div> <!--vertical line-->
</div>
<div class="col-6"> <!--right[enter image description here][1] column-->
<p>To fully cover your body, you'll need about 1 ounce of sunscreen or just enough to fill a shot glass.</p>
</div>
It looks like the issue is you aren't using the .container > .row > .col convention. You've skipped the .container, and are sometimes skipping the .row. Additionally, you are not using the grid for the section shown in your screenshot.
Refer to the Bootrap documentation when there are Bootstrap issues.
https://getbootstrap.com/docs/5.0/layout/grid/
The first thing is you should wrap all/most of your <body> content in a <div class="container-fluid">.
Then add any missing .rows.
This is what you have:
This is what you should have:
Write the contents of that next section to match your design.
ex.
<div class="row">
<div class="col-sm-6">
<div class="row">
<div class="col-6" style="border-right: 2px solid orange;">
<div class="circle side" data-sr-id="9" style="visibility: visible; opacity: 1; transition: opacity 2s cubic-bezier(0.5, 0, 0, 1) 0s;">
<img src="./chemical#2x.png" alt="chemical" class="icon">
</div>
</div>
<div class="col-6">
<h5 class="side">1 Shot Glass<br>or 1 oz.</h5>
<div class="line v side"></div>
</div>
</div>
</div>
<div class="col-sm-6">
<p>To fully cover your body, you'll need about 1 ounce of sunscreen or just enough to fill a shot glass. </p>
</div>
</div>
You can Refere Bootstrap Grid System
Here:https://www.w3schools.com/bootstrap/bootstrap_grid_system.asp
It will fix your problem
I want to set my code to auto-calculate equal height in inside of .col, because for example inside .col I have <h2> and <p> which could have different number of rows, so height of this element will be different for every .col, I would like to get same height for all rows inside .col.
I tried to use flexbox utilities, but I didn't find a solution, so I am wondering if grid will help me get what I want to get, but I don't know if display: grid inherits height of flexbox elements?
Here is my code:
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="header-bottom-box">
<h2>Projektowanie <b>stron</b></h2>
<div class="img-container">
<img src="http://irson.linuxpl.eu/images/projektowanie-stron.jpg" class="img-fluid" alt="Projektowanie stron">
</div>
<p>Projektowanie oraz tworzenie serwisów internetowych.</p>
<div class="text-right">
więcej
</div>
</div>
</div>
<div class="col-md-4">
<div class="header-bottom-box">
<h2>Pozycjonowanie <b>stron</b></h2>
<div class="img-container">
<img src="http://irson.linuxpl.eu/images/pozycjonowanie-stron.jpg" class="img-fluid" alt="Pozycjonowanie stron">
</div>
<p>Zwiększ pozycję swojej strony www w wynikach wyszukiwania.</p>
<div class="text-right">
więcej
</div>
</div>
</div>
<div class="col-md-4">
<div class="header-bottom-box">
<h2>Outsourcing <b>IT</b></h2>
<div class="img-container">
<img src="http://irson.linuxpl.eu/images/outsourcing-it.jpg" class="img-fluid" alt="Outsourcing IT">
</div>
<p>Outsourcing informatyczny Profesjonalna opieka informatyczna dla firm.</p>
<div class="text-right">
więcej
</div>
</div>
</div>
</div>
</div>
https://codepen.io/anon/pen/jRweow
I thought about using display: grid to .header-bottom-box and equal height of inside element.
EDIT
I tried to use GIRD:
And it works like I want to, but I don't know why I get this white space, how to delete it?
this is normal sir,
this all happen because of last col. text is less then first and second.
I am trying to display the date before an h2 title.
The date is displayed as two boxes, one above the other.
The top box contains the day of the month, the bottom box the month and year.
the HTML (with test CSS) is as follows:-
<div style="text-align: center;display: inline">
<div style="border-radius:5px;font-size:20px;color:black;background-color:yellow;width:45px;height:30px">
12
</div>
<div style="border-radius:3px;font-size:10px;color:#fff;background-color:black;width:45px;height:15px">
Dec-16
</div>
</div>
This displays nicely at the beginning of the line.
But
This is H2 text
does not display on the sane line but the next one.
Because my "date container" is made of nested divs, this does not appear to align correctly.
This works fine aligned on the same line
<div style="display:inline">This is DIV text</div>
<h2 style="display:inline">This is H2 text</h2>
This does not align correctly (as I wish)
<div style="text-align: center;display: inline">
<div style="border-radius:5px;font-size:20px;color:black;background-color:yellow;width:45px;height:30px">
12
</div>
<div style="border-radius:3px;font-size:10px;color:#fff;background-color:black;width:45px;height:15px">
Dec-16
</div>
</div>
<h2 style="display:inline">This is H2 text</h2>
TIA
Ephraim
<body style="display:table">
<div style="text-align: center;display: table-cell">
<div style="border-radius:5px;font-size:20px;color:black;background-color:yellow;width:45px;height:30px">
12
</div>
<div style="border-radius:3px;font-size:10px;color:#fff;background-color:black;width:45px;height:15px">
Dec-16
</div>
</div>
<h2 style="display:table-cell; vertical-align:middle; padding-left: 10px;">This is H2 text</h2>
</body>
Add
display: table for body
display:table-cell for div and h2
vertical-align:middle for h2
It works perfectly fine
Hope below snippet works for you.
<div style="text-align: center; float: left">
<div style="border-radius:5px;font-size:20px;color:black;background-color:yellow;width:45px;height:30px">
12
</div>
<div style="border-radius:3px;font-size:10px;color:#fff;background-color:black;width:45px;height:15px">
Dec-16
</div>
</div>
<h2 style="float: left; margin-left: 10px;">This is H2 text</h2>
Use inline-block instead of inline.
<div style="text-align: center;display: inline-block">
<div style="border-radius:5px;font-size:20px;color:black;background-color:yellow;width:45px;height:30px">
12
</div>
<div style="border-radius:3px;font-size:10px;color:#fff;background-color:black;width:45px;height:15px">
Dec-16
</div>
</div>
<h2 style="display:inline-block">This is H2 text</h2>
I am using uikit 2.8.0. I am trying to create a two column grid structure. But the two columns don't appear adjacent to each other. The second column slides down the first one.
<body>
<div class="uk-container uk-container-center uk-margin-large-bottom">
<nav var code.......>
<div class="uk-grid" data-uk-grid-margin>
<div class="uk-width-medium-1-1 uk-text-center">
<h1>Tell us more about yourself</h1>
</div>
</div>
<div class="uk-grid" data-uk-grid-match="{target:'.equal-height'}">
<div class="uk-width-large-6-10" style="margin: 0 20% 0 20%;">
<div class="uk-width-7-10 uk-width-small-1-1 uk-width-medium-7-10 uk-width-large-7-10" style="border: 1px solid #B4B3B3;height:100px;">
</div>
<div class="uk-width-3-10 uk-width-small-1-1 uk-width-medium-3-10 uk-width-large-3-10" style="border: 1px solid #B4B3B3;height:100px;">
</div>
</div>
</div>
</div>
I tried many options. But come what may, the second grid would not stay side by side to the first one.
How can I fix this? Any tool that I can use to debug the layout? I am using chrome developer tools without any success.
You needed to add class ".uk-grid" to the div with styled margin (uk-width-large-6-10), as you want to make a grid inside that element.
Plus this, the "Target" element should target to something existing, best to "uk-panel" placed inside the element with "uk-width".
<div class="uk-container uk-container-center uk-margin-large-bottom">
<nav var code.......>
<div class="uk-grid" data-uk-grid-margin>
<div class="uk-width-medium-1-1 uk-text-center">
<h1>Tell us more about yourself</h1>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-large-6-10 uk-grid" style="margin: 0 20% 0 20%;" data-uk-grid-match="{target:'.uk-panel'}">
<div class="uk-width-7-10 uk-width-small-1-1 uk-width-medium-7-10 uk-width-large-7-10" style="background-color:green; height:100px;">
<div class="uk-panel"> </div>
</div>
<div class="uk-width-3-10 uk-width-small-1-1 uk-width-medium-3-10 uk-width-large-3-10" style="background-color:red; height:100px;">
<div class="uk-panel"> </div>
</div>
</div>
</div>
The following is my HTML:
<div class=container">
<div class="row">
<h2 class="text-center">Enter your name below</h2>
<div class="col-md-6 center">
<img class="profile-picture" ng-src="../Content/images/default-avatar.png" src="../Content/images/default-avatar.png">
</div>
<div class="col-md-6 center">
<h3>Profile name: N/A</h3>
<h3>Status: Waiting for user input</h3>
</div>
</div>
</div>
My css is the following (along with bootstrap):
.profile-picture
{
max-width: 200px;
max-height: 200px;
}
.center
{
margin: 0 auto;
float: none;
}
This produces the following output:
The way I want it to display is as shown below:
How can I achieve this? Shouldn't they get displayed on the SAME line seeing as they are part of the same row? Each has a length of 6 so why don't they horizontally align?
The problem is you're removing the necessary float on the columns (by setting float:none to .center). Remove that .center class altogether, it's not needed. You are also missing row divs...
Note, I added a row around the the h2 tag as well. For ease-of-use and proper formatting, that tag needs to be wrapped as well. Helps keep the formatting in check. ;)
Also, you shouldn't have two <h3> tags one after another like that. Use <p> instead of the second h3 - or better yet, just use one <h3> tag and use <br /> to break the one h3 into two lines (see below).
<div class=container">
<div class="row">
<h2 class="text-center">Enter your name below</h2>
</div>
<div class="row">
<div class="col-md-6">
<img class="profile-picture" ng-src="../Content/images/default-avatar.png" src="../Content/images/default-avatar.png">
</div>
<div class="col-md-6">
<h3>Profile name: N/A <br />
Status: Waiting for user input</h3>
</div>
</div>
</div>
Never apply any styles or classes to elements with grid classes, if you're not really know what you are doing. Use a nested div instead if you need to change something:
<div class=container">
<h2 class="text-center">Enter your name below</h2>
<div class ="row">
<div class="col-md-6">
<div class ="center">
<img class="profile-picture" ng-src="../Content/images/default-avatar.png" src="../Content/images/default-avatar.png">
</div>
</div>
<div class="col-md-6">
<div class ="center">
<h3>Profile name: N/A</h3>
<h3>Status: Waiting for user input</h3>
</div>
</div>
</div>
</div>
With Bootstrap, you have to include a div with an class of row, so something like this:
<div class="row">
<div class="col-md-6 center">
<img class="profile-picture" ng-src="../Content/images/default-avatar.png" src="../Content/images/default-avatar.png">
</div>
<div class="col-md-6 center">
<h3>Profile name: N/A</h3>
<h3>Status: Waiting for user input</h3>
</div>
</div>
See Bootstrap's documentation on their grid system.