Doing the MIMO HTML course and I've come across an issue where i cant get both elements with the class="column" attribute to align horizontally with display: inline-block;
I've already tried float:right and other properties to make them line up but something is stopping this happening
.column {
min-width: 300px; /*DOES NOT WORK*/
display: inline-block; /*DOES NOT WORK*/
vertical-align: top; /*DOES NOT WORK*/
}
<div id="footer">
<!--Footer-->
<div class="container">
<div class="column">
<h4>My Links
<!--My Links Header-->
</h4>
<p>
<a href="https://soundcloud.com/discover">Soundcloud <!--Link-->
</a>
<br>
<a href="https://www.youtube.com">Youtube <!--Link-->
</a>
</p </div>
<div class="column">
<!--My Story Header-->
<h4>My Story
</h4>
<p>Hey there! I'm aspiring music website creator!
</p>
</div>
</div>
</div>
The display: inline-block; should put the elements side-by-side according to MIMO but this doesn't happen
you can float it to left.
you also have a wrong closing tag here...
</p </div>
.column {
min-width: 300px;
display: inline-block;
vertical-align: top;
float: left;
}
<div id="footer">
<!--Footer-->
<div class="container">
<div class="column">
<h4>My Links
<!--My Links Header-->
</h4>
<p>
Soundcloud <!--Link-->
<br>
Youtube <!--Link-->
</p>
</div>
<div class="column">
<!--My Story Header-->
<h4>My Story
</h4>
<p>Hey there! I'm aspiring music website creator!
</p>
</div>
</div>
</div>
Remove the broken </p in your HTML. And add float: left; to the column class.
you can use this example:
.column {
min-width: 300px; /*DOES NOT WORK*/
display: inline-block; /*DOES NOT WORK*/
vertical-align: top; /*DOES NOT WORK*/
}
<div id="footer">
<!--Footer-->
<div class="container">
<div class="column">
<h4>My Links
<!--My Links Header-->
</h4>
<p>
<a href="https://soundcloud.com/discover">Soundcloud <!--Link-->
</a>
<br>
Youtube
</p>
</div>
<div class="column">
<!--My Story Header-->
<h4>My Story
</h4>
<p>Hey there! I'm aspiring music website creator!
</p>
</div>
</div>
</div>
Consider using flex. In your case, you would need to set the display to flex to to .container:
.container{
display: flex;
}
If you want both children to have the same width you can simply add flex: 1 to their CSS properties.
You can check the following snippet.
.container{
display: flex;
}
.column{
flex: 1;
}
<div id="footer">
<!--Footer-->
<div class="container">
<div class="column">
<h4>My Links
<!--My Links Header-->
</h4>
<p>
<a href="https://soundcloud.com/discover">Soundcloud <!--Link-->
</a>
<br>
Youtube
</p>
</div>
<div class="column">
<!--My Story Header-->
<h4>My Story
</h4>
<p>Hey there! I'm aspiring music website creator!
</p>
</div>
</div>
</div>
Related
[Output Image I'm getting
.featuress{
width:70%;
margin-left:20%;
display: flex;
align-items: center;
padding-bottom:30px;
}
.logo{
min-width: 60px;
margin:10px;
text-align:center;
}
.text{
display: inline-block;
background-color: #ffa600;
}
body, h2, p {
margin:0;
}
.featuress{
width:70%;
margin-left:20%;
display: flex;
align-items: center;
padding-bottom:30px;
}
.logo{
min-width: 60px;
margin:10px;
text-align:center;
}
.text{
display: inline-block;
background-color: #ffa600;
}
body, h2, p {
margin:0;
}
<div class="featuress">
<section id="features">
<div class="premium">
<div class="logo1">
<img class="logo" src="https://cdn-icons-png.flaticon.com/512/70/70535.png" width="40" alt="premium" />
</div>
<div class="text text1">
<h2>Premium Materials</h2>
<p>Our trombones use the shiniest brass which is sourced locally. This will increase the longevity of your purchase.</p>
</div>
</div>
<div class="shipping">
<div class="logo2">
<img class="logo" src="https://cdn.pixabay.com/photo/2020/09/14/20/39/vans-5572117__480.png" alt="shipping" width="60" />
</div>
<div class="text text2">
<h2>Fast Shipping</h2>
<p>We make sure you recieve your trombone as soon as we have finished making it. We also provide free returns if you are not satisfied.</p>
</div>
</div>
<div class="quality">
<div class="logo3">
<img class="logo loggo3" src="https://i.pinimg.com/736x/0b/a2/d1/0ba2d192c9b874a4df11af1a90a6d1ad.jpg" alt="quality" width="60"/>
</div>
<div class="text text3">
<h2>Quality Assurance</h2>
<p>For every purchase you make, we will ensure there are no damages or faults and we will check and test the pitch of your instrument.</p>
</div>
</div>
</section>
</div>
][1]Intended Output Style
<div class="featuress">
<section id="features">
<div class="premium">
<div class="logo1">
<img class="logo" src="https://cdn-icons-png.flaticon.com/512/70/70535.png" width="40" alt="premium" />
</div>
<div class="text text1">
<h2>Premium Materials</h2>
<p>Our trombones use the shiniest brass which is sourced locally. This will increase the longevity of your purchase.</p>
</div>
</div>
<div class="shipping">
<div class="logo2">
<img class="logo" src="https://cdn.pixabay.com/photo/2020/09/14/20/39/vans-5572117__480.png" alt="shipping" width="60" />
</div>
<div class="text text2">
<h2>Fast Shipping</h2>
<p>We make sure you recieve your trombone as soon as we have finished making it. We also provide free returns if you are not satisfied.</p>
</div>
</div>
<div class="quality">
<div class="logo3">
<img class="logo loggo3" src="https://i.pinimg.com/736x/0b/a2/d1/0ba2d192c9b874a4df11af1a90a6d1ad.jpg" alt="quality" width="60" />
</div>
<div class="text text3">
<h2>Quality Assurance</h2>
<p>For every purchase you make, we will ensure there are no damages or faults and we will check and test the pitch of your instrument.</p>
</div>
</div>
</section>
</div>
This is the HTML bit of the code I tried writing and the intended format I was looking for is attached along. I just cant quite get it the way its shown. It'd be really helpful if I could be helped with how to align and style just this part of the site using CSS
You can use display:flex and align-items:center on your features. I added some style to fit a little bit like your screen.
body, h2, p {
margin:0;
}
.feature {
display:flex;
align-items: center;
padding-bottom:30px;
}
.logo{
min-width: 60px;
margin:10px;
text-align:center;
}
<div class="feature">
<div class="logo">
<img src="https://cdn-icons-png.flaticon.com/512/70/70535.png" width="40"/>
</div>
<div>
<h2>Premium Materials</h2>
<p>Our trombones use the shiniest brass which is sourced locally. This will increase the longevity of your purchase.</p>
</div>
</div>
<div class="feature">
<div class="logo">
<img src="https://cdn.pixabay.com/photo/2020/09/14/20/39/vans-5572117__480.png" width="60" />
</div>
<div>
<h2>Fast Shipping</h2>
<p>We make sure you recieve your trombone as soon as we have finished making it. We also provide free returns if you are not satisfied.</p>
</div>
</div>
<div class="feature">
<div class="logo">
<img src="https://i.pinimg.com/736x/0b/a2/d1/0ba2d192c9b874a4df11af1a90a6d1ad.jpg" width="60" />
</div>
<div>
<h2>Quality Assurance</h2>
<p>For every purchase you make, we will ensure there are no damages or faults and we will check and test the pitch of your instrument.</p>
</div>
</div>
EDIT
Here is an exemple of what to select with display:flex, take a look at Flexbox (MDN).
.container{
border:1px solid black;
}
.d-flex{
display:flex;
}
.orange{
background-color:orange;
}
.green{
background-color:green;
}
.pink{
background-color:pink;
}
<div class="d-flex container">
<div class="box-container orange">
<div class="box">A</div>
<div class="box">B</div>
<div class="box">C</div>
</div>
<div class="box-container green">
<div class="box">D</div>
<div class="box">E</div>
<div class="box">F</div>
</div>
<div class="d-flex box-container pink">
<div class="box">G</div>
<div class="box">H</div>
<div class="box">I</div>
</div>
</div>
I have the following jumbotron:
Created via:
<div class="col-sm-2">
<div class="jumbotron jumbotron-fluid top-space">
<div class="container">
<h1 class="display-6">Initiatives</h1>
<p class="lead">The other good stuff.</p>
<ul>
<li>
Start an Initiative »</li>
<li>
More Information »</li>
</ul>
</div>
</div>
<div class="jumbotron jumbotron-fluid top-space">
<div class="container">
<h1 class="display-6">News</h1>
<p class="lead">Our Search Tool. <br> Love at first, second, third, fourth, fifth, and sixth sight.</p>
Try it out »
</div>
</div>
</div>
I want an icon on the red square. How can I add and align it to my h1, display-6?
.col-sm-2 > div:first-child .display-6::after{
content: "" ;
width: 40px;
height: 40px;
background-color: red;
display: block;
margin-left: 20px;
}
.col-sm-2 > div:first-child .display-6{
display: inline-flex;
}
<div class="col-sm-2">
<div class="jumbotron jumbotron-fluid top-space">
<div class="container">
<h1 class="display-6">Initiatives</h1>
<p class="lead">The other good stuff.</p>
<ul>
<li>
Start an Initiative »</li>
<li>
More Information »</li>
</ul>
</div>
</div>
<div class="jumbotron jumbotron-fluid top-space">
<div class="container">
<h1 class="display-6">News</h1>
<p class="lead">Our Search Tool. <br> Love at first, second, third, fourth, fifth, and sixth sight.</p>
Try it out »
</div>
</div>
</div>
Here is my code:
.region-footer {
display: flex;
justify-content: space-between;
align-items: center;
}
<div class="region region-footer">
<nav role="navigation" aria-labelledby="block-mytheme-footer-menu" id="block-mytheme-footer" class="contextual-region">
<ul class="menu menu--footer nav">
<liAbout
</li>
<li>Contact</li>
<li> Privacy Policy</li>
</ul>
</nav>
<section data-quickedit-entity-id="block_content/16" id="block-socialmedia" class="contextual-region block block-block-content block-block-content3e0c4d11-72cf-4565-ae42-0da66a2df37d clearfix" data-quickedit-entity-instance-id="0">
<div data-quickedit-field-id="block_content/16/body/en/full" class="field field--name-body field--type-text-with-summary field--label-hidden field--item quickedit-field">
<div class="social-media">
<a class="social-a" href="https://twitter.com/">
<img src="/themes/img/twitter.png">
</a>
<a class="social-a" href="https://www.instagram.com/">
<img src="/themes/img/instagram.png">
</a>
<a class="social-a" href="https://dribbble.com/">
<img src="/themes/img/dribbble.png">
</a>
</div>
</div>
</section>
<section data-quickedit-entity-id="block_content/14" id="block-copyright" class="contextual-region block block-block-content block-block-contentd9975090-e973-43a8-bd2d-ec3a21f65f51 clearfix" data-quickedit-entity-instance-id="0">
<div data-quickedit-field-id="block_content/14/body/en/full" class="field field--name-body field--type-text-with-summary field--label-hidden field--item quickedit-field">
<div class="copyright">
<p>© MySite 2019</p>
</div>
</div>
</section>
</div>
Here is what my website looks like and what I'm trying to achieve: https://imgur.com/a/FEa4GVQ
I've tried experimenting with align-self on each item, setting the copyright to margin-right: auto, setting each element to width: 50% etc. but nothing is working
Flexbox Solution
Here is a simple example. Both items on the first row take up 50% of space. The last item is pushed to the far right using margin-left: auto.
.container {
display: flex;
flex-wrap: wrap;
}
.one, .two {
flex-basis: 50%;
}
.two {
text-align: right;
}
.three {
margin-left: auto;
}
<div class="container">
<div class="one">
one
</div>
<div class="two">
two
</div>
<div class="three">
three
</div>
</div>
jsFiddle
Grid Solution
There are many ways to handle this using Grid—I just picked this one because I like grid-template-areas. Note: the dot (.) in Grid represents an empty grid area.
.container {
display: grid;
grid-template-areas: "one two"
". three";
}
.one {
grid-area: one;
}
.two {
grid-area: two;
}
.three {
grid-area: three;
}
.two, .three {
text-align: right;
}
<div class="container">
<div class="one">
one
</div>
<div class="two">
two
</div>
<div class="three">
three
</div>
</div>
jsFiddle
You can wrap two section elements within div element
<div class="region region-footer">
<nav role="navigation" aria-labelledby="block-mytheme-footer-menu" id="block-mytheme-footer" class="contextual-region">
<ul class="menu menu--footer nav">
<li>About</li>
<li>Contact</li>
<li>
Privacy Policy
</li>
</ul>
</nav>
<div class="right-content">
<section data-quickedit-entity-id="block_content/16" id="block-socialmedia" class="contextual-region block block-block-content block-block-content3e0c4d11-72cf-4565-ae42-0da66a2df37d clearfix" data-quickedit-entity-instance-id="0">
<div data-quickedit-field-id="block_content/16/body/en/full" class="field field--name-body field--type-text-with-summary field--label-hidden field--item quickedit-field">
<div class="social-media">
<a class="social-a" href="https://twitter.com/">
<img src="/themes/img/twitter.png">
</a>
<a class="social-a" href="https://www.instagram.com/">
<img src="/themes/img/instagram.png">
</a>
<a class="social-a" href="https://dribbble.com/">
<img src="/themes/img/dribbble.png">
</a>
</div>
</div>
</section>
<section data-quickedit-entity-id="block_content/14" id="block-copyright" class="contextual-region block block-block-content block-block-contentd9975090-e973-43a8-bd2d-ec3a21f65f51 clearfix" data-quickedit-entity-instance-id="0">
<div data-quickedit-field-id="block_content/14/body/en/full" class="field field--name-body field--type-text-with-summary field--label-hidden field--item quickedit-field">
<div class="copyright">
<p>© MySite 2019</p>
</div>
</div>
</section>
</div>
</div>
Remember CSS of two sections should use display: block; for one is at top and the other is at bottom.
I'm trying to create a 'Meet the Team' intranet page, but I just can't seem to figure out the best way to do it. So, firstly, here is my code;
`<html>
<head>
<h1>Meet the Team</h1>
</head>
<body>
<h3>Joe Bloggs</h3>
<div id="joe" style="position:relative;width:300px;height:350px;background-color:#959595;">
<p>Test paragraph</p>
</div>
<h3>John Smith</h3>
<div id="john" style="position:relative;width:300px;height:350px;background-color:#959595;">
<p>Test paragraph</p>
</div>
<h3>Jane Doe</h3>
<div id="jane" style="position:static;top:50%;float:right;width:300px;height:350px;background-color:#959595;">
<p>Test paragraph</p>
</div>
</body>
</html>`
Now, basically the 'divs' when set to relative are all just going down the page, but I want 3 in a row and then going down in columns which will display the persons name and then a description of their role. So..
123
456
789
I've tried using the other position elements such as absolute, but it doesn't seem to work to put the divs side by side. I also want to know the best way on including the <h3> in the div but not having the background color on it. And finally, I know that inline CSS is probably not the best thing to use here, but I wanted slightly different background colors for each div.
Is that what are you looking for?
#team{
background-color: #e7eaea;
width: 100%;
}
#team > div{
background-color: #a0c3ce;
margin: 1%;
width: 31%;
float: left;
}
h1, h3{
width: 100%;
text-align: center;
}
<html>
<head>
<title>Meet the Team</title>
</head>
<body>
<h1>Meet the Team</h1>
<div id="team">
<div id="joe">
<h3>Joe Bloggs</h3>
<p>Test paragraph</p>
</div>
<div id="john">
<h3>John Smith</h3>
<p>Test paragraph</p>
</div>
<div id="jane">
<h3>Jane Doe</h3>
<p>Test paragraph</p>
</div>
</div>
</body>
</html>
You need to do two things :
add in each div's
display:inline-block;
Secondly, its good to make a css class and use that for each div instead of copying css into all.
For example
<style>
.box{width:300px;height:350px;background-color:#959595;display:inline;}
</style>
In HTML,
<div id="joe" class="box">some content here</div>
<div id="john" class="box">some content here</div>
<div id="jane" class="box">some content here</div>
Here is one more solution
.info {
display: inline-block;
width: 32%;
height: 300px;
margin-top: 5px;
text-align: center;
background: orange;
}
.info h3 {
display: block;
background: lightgreen;
margin: 0;
}
.info p{
display: block;
padding-top: 10px;
margin: 0;
}
<h1>Meet the Team</h1>
<div id="joe" class="info">
<h3>Joe Bloggs</h3>
<p>Test paragraph</p>
</div>
<div id="john" class="info">
<h3>John Smith</h3>
<p>Test paragraph</p>
</div>
<div id="jane" class="info">
<h3>Jane Doe</h3>
<p>Test paragraph</p>
</div>
<div id="john" class="info">
<h3>John Smith</h3>
<p>Test paragraph</p>
</div>
<div id="jane" class="info">
<h3>Jane Doe</h3>
<p>Test paragraph</p>
</div>
add display:inline-block; in every <div>'s style
There are many ways to do what you want. One is to create div 'rows' to wrap every line 3 divs:
<div class="row" style="width: 100%">
<div class="col" style="width: 33%; float: left">1</div>
<div class="col" style="width: 33%; float: left">2</div>
<div class="col" style="width: 33%; float: left">3</div>
</div>
<div class="row" style="width: 100%">
<div class="col" style="width: 33%; float: left">4</div>
<div class="col" style="width: 33%; float: left">5</div>
<div class="col" style="width: 33%; float: left">6</div>
</div>
Each 'col' element should be a fraction of the container (33% in this case). Yo can do it better defining a style for rows and cols:
.row {
width: 100%;
}
.col {
width: 33%;
float: left;
}
<div class="row">
<div class="col">1</div>
<div class="col">2</div>
<div class="col">3</div>
</div>
<div class="row">
<div class="col">4</div>
<div class="col">5</div>
<div class="col">6</div>
</div>
This can be solved as shown hereby:
#team {
width: 100%;
}
#team > div {
width: 31%;
margin: 1%;
float: left;
background-color:#959595;
}
<html>
<head>
<h1>Meet the Team</h1>
</head>
<body>
<div id="team">
<div id="joe">
<h3>Joe Bloggs</h3>
<p>Test paragraph</p>
</div>
<div id="john">
<h3>John Smith</h3>
<p>Test paragraph</p>
</div>
<div id="jane">
<h3>Jane Doe</h3>
<p>Test paragraph</p>
</div>
</div>
</body>
</html>
But instead of applying the css you can use the twitter bootstrap which already has this implemented in a much easier way.
You can take help from the code below:
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<h1>Meet the Team</h1>
</head>
<body>
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-4">
<h3>Joe Bloggs</h3>
<p>Test paragraph</p>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<h3>John Smith</h3>
<p>Test paragraph</p>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<h3>Jane Doe</h3>
<p>Test paragraph</p>
</div>
</div>
</body>
</html>
In this code only one row is created but you can create multiple rows and divide it into columns.
For further help refer, [1]: https://getbootstrap.com/examples/grid/
imageI have a block of images but they are not connected to one another, I need to remove the spaces and make them looked attached. I have tried the following but doesn't work
img {
border: 0 none;
box-shadow: none;
padding:0px;
float: left;
display:block;
float:left;
line-height:0;
}
This is my html
<div class="col-xs-4 col-md-3 ">
<div class="hovereffect">
<img src="images/plasma.jpg" alt="Plasma" id="space">
<div class="overlay">
<h3>
Creativity on Combined Photos
</h3>
<p>
LINK HERE
</p>
</div>
</div>
</div>
Please see the image where the problem is.
.test{
display:flex
}
<div class="test">
<div class="hovereffect">
<img src="http://placehold.it/350x150">
<div class="overlay">
<h3>
Creativity on Combined Photos
</h3>
<p>
LINK HERE
</p>
</div>
</div>
<div class="hovereffect">
<img src="http://placehold.it/350x150">
<div class="overlay">
<h3>
Creativity on Combined Photos
</h3>
<p>
LINK HERE
</p>
</div>
</div>
</div>
is it something like this you are looking for?
I did this with flexbox you just give the parent of the images display:flex;
if you not want them one next to each other you can do it this way
.test{
display:flex;
flex-direction:column
}
.hovereffect{
display:flex;
}
<div class="test">
<div class="hovereffect">
<img src="http://placehold.it/350x150">
<div class="overlay">
<h3>
Creativity on Combined Photos
</h3>
<p>
LINK HERE
</p>
</div>
</div>
<div class="hovereffect">
<img src="http://placehold.it/350x150">
<div class="overlay">
<h3>
Creativity on Combined Photos
</h3>
<p>
LINK HERE
</p>
</div>
</div>
</div>
Please try this:
img {
border: 0 none;
box-shadow: none;
padding:0px;
float: left;
display:block;
margin:0;
line-height:0;
}