Im trying to put together some images together with an text under the images which will work as an menu, which should be centered horizontal under an header. The website is supposed to work as an responsive website. The HTML and CSS code is currently looking like this:
Edited
I want 5 images, each one of them shall have a text under them. And I want the my images together with the text to be centered.
HTML
<nav>
<div id="content">
<img src="ikoner/icon_90_2.png"/>
<div class="text">Utvecklingen sedan 90-talet</div>
</div>
<div id="content">
<img src="ikoner/icon_html5.png"/>
<div class="text">HTML5</div>
</div>
<div id="content">
<img src="ikoner/icon_html5video.png"/>
<div class="text">HTML5 Video</div>
</div>
<div id="content">
>img src="ikoner/icon_responsive.png"/>
<div class="text">Responsive Webdesign</div>
</div>
<div id="content">
<img src="ikoner/icon_heart.png"/>
<div class="text">Emotional Design</div>
</div>
</nav>
CSS
#content {
position: relative;
width: 15%;
display: inline-block;
text-align: center;
margin-left: auto;
margin-right: auto;
}
#content img {
padding-top: 370px;
width: 100px;
}
.text {
font-size: 12px;
font-family: 'ciclethin';
text-decoration: none;
}
You're not aligning your "Nav" div anywhere.
So, I've changed the id="content" to classes, because IDs should be unique to the page.
Set nav element to text-align:center. Here's a fiddle, and the relevant code:
http://jsfiddle.net/cw16tkdn/2/
<nav>
<div class="content">
<img src="http://placekitten.com/g/200/200" />
<div class="text">Utvecklingen sedan 90-talet
</div>
</div>
<div class="content">
<img src="http://placekitten.com/g/200/200" />
<div class="text">HTML5
</div>
</div>
<div class="content">
<img src="http://placekitten.com/g/200/200" />
<div class="text">HTML5 Video
</div>
</div>
<div class="content">
<img src="http://placekitten.com/g/200/200" />
<div class="text">Responsive Webdesign
</div>
</div>
<div class="content">
<img src="http://placekitten.com/g/200/200" />
<div class="text">Emotional Design
</div>
</div>
</nav>
and CSS:
nav {
text-align:center;
}
.content {
display: inline-block;
text-align: center;
}
.content img {
width: 100px;
}
.text {
font-size: 12px;
font-family:'ciclethin';
text-decoration: none;
}
maybe you want this: (i have changed id=content with class=content in html code!)
.content {
position: relative;
width: 100px;
display: inline-block;
height: 520px;
text-align: center;
vertical-align:bottom;
}
.content img {
padding-top: 370px;
width: 100px;
display:block;
margin: auto;
}
.text a {
font-size: 12px;
font-family: 'ciclethin';
text-decoration: none;
}
.text {
height: 3em;
}
Related
I am trying to make my own web page.
so what i want is text on left and image on right.
problem 1: image will not change the size to 300px
problem 2: i am trying to have the image on the right side, I tried using float and it did not work.
p,
h1 {
margin: 0px;
padding: 0px;
}
.top {
margin-left: 20%;
}
.top img {
float: right;
margin-right: 35%;
width: 300px;
height: 300px;
}
<div class="top">
<div class="image">
<img src="myimage.jpg">
</div>
<div class="words">
<h1>Welcome</h1>
<p>My name is Jamie Smith<br>I am a student at CSUN<br><br>Welcome, and thank you for visiting my page.
</p>
<br>
<h1>Contact Info</h1>
<p>jamie.smith#csun.edu<br></p>
</div>
<div class="list">
Pages:
</div>
</div>
Try this:
p,h1{
margin: 0px;
padding: 0px;
}
.top{
display: flex;
flex-wrap: wrap;
flex-direction: row-reverse;
}
.words, .list{
width: 100%;
}
<div class="top">
<div class="image">
<img src="myimage.jpg">
</div>
<div class="words">
<h1>Welcome</h1>
<p>My name is Jamie Smith<br>I am a student at CSUN<br><br>Welcome, and thank you for visiting
my
page.</p><br>
<h1>Contact Info</h1>
<p>jamie.smith#csun.edu<br></p>
</div>
<div class="list">
Pages:
</div>
</div>
try this code:
p,h1{
margin: 0px;
padding: 0px;
}
.top{
height: auto;
background-color: aqua;
padding: 20px;
display: inline-block;
width: 100%;
}
.top img{
float:right;
width:300px;
height:300px;
}
<body>
<div class="top">
<div class="image">
<img src="myimage.jpg">
</div>
<div class="words">
<h1>Welcome</h1>
<p>My name is Jamie Smith<br>I am a student at CSUN<br><br>Welcome, and thank you for visiting
my
page.</p><br>
<h1>Contact Info</h1>
<p>jamie.smith#csun.edu<br></p>
</div>
<div class="list">
Pages:
</div>
</ul>
</div>
</body>
The image gets 300px width, but for making it better add a .image class in your css. Use flex display instead of using float. to set your image on right you can simply add rtl direction to div with top class or put it after div with word class.
p,h1{
margin: 0px;
padding: 0px;
}
p,h1{
margin: 0px;
padding: 0px;
}
.top{
display: flex;
justify-content: center;
align-items: center;
}
.top .image img{
width:300px;
height:300px;
}
<div class="top">
<div class="words">
<h1>Welcome</h1>
<p>My name is Jamie Smith<br>I am a student at CSUN<br><br>Welcome, and thank you for visiting
my
page.</p><br>
<h1>Contact Info</h1>
<p>jamie.smith#csun.edu<br></p>
</div>
<div class="list">
Pages:
</div>
<div class="image">
<img src="http://simpleicon.com/wp-content/uploads/user1-256x256.png" />
</div>
</div>
I want to align in-line a profile image and its username inline. Here's the code:
<div id="post">
<div class="proPic">
<img title="proPic" alt="Profile Picture" src="">
</div>
<h3>Username</h3>
<p>Text post</p>
</div>
What's the best way to do this? I'd like to see both HTML and CSS methods.
Here's a version using less code than you have already ;)
body {
font-family: arial;
}
.profile {
width: 25%;
float: right;
background: pink;
}
.profile h3 {
margin: 0;
padding: 0;
font-size: 14px;
min-height: 50px; /*Just for demo*/
}
.content {
width: 70%;
float: left;
background: #ccc;
min-height: 200px; /*Just for demo*/
}
<div class="post">
<div class="profile">
<img title="proPic" alt="Profile Picture" src="">
<h3>Username</h3>
</div>
<div class="content">
Text post
</div>
</div>
I am trying to align logos horizontally with the respective text underneath them so they look nice and in order. Currently, they are just vertical. I have searched this site and many others, and tried different solutions but nothing seems to work. Here is my code.
.intro-text {
color: #000000;
display: block;
width: 100%;
margin: 50px 0 0 0;
text-align: justify;
line-height: 1.8em;
}
.intro-text-3d {
color: #000000;
display: block;
width: 100%;
text-align: center;
line-height: 1.8em;
}
.intro-text-process {
color: #000000;
display: block;
width: 100%;
text-align: center;
line-height: 1.8em;
}
.intro-text-toolset {
color: #000000;
display: block;
width: 100%;
text-align: center;
line-height: 1.8em;
}
/** Logos **/
.logos-all {
display: block;
text-align: center;
margin: 0 auto;
}
img {
display: inline-block;
margin: 0 auto;
vertical-align: middle;
border: 0;
line-height: 50px;
max-width: 100%;
width: 5%;
height: auto;
margin-bottom: .95em;
}
strong {
display: block;
font-weight: 700;
text-align: center;
}
section h4 {
text-align: center;
}
<article>
<section>
<p class="intro-text">
Some text goes here.
</p></div>
<div>
<img src="http://lorempixel.com/80/79" alt="CSS3" height="80" width="79"/>
<strong>CSS3</strong>
</div>
<div>
<img src="http://lorempixel.com/80/79" alt="Javascript" height="80" width="79"/>
<strong>Javascript</strong>
</div>
<div>
<img src="http://lorempixel.com/80/79" alt="Wordpress" height="80" width="79"/>
<strong>Wordpress</strong>
</div>
<div>
<img src="http://lorempixel.com/80/79" alt="PhP" height="80" width="79"/>
<strong>PhP</strong>
</div>
</div>
</section>
<section>
<p class="intro-text-3d">
Some text goes here
</p>
<div class="logos-all">
<div>
<img src="img/3ds max-logo.png" alt="3ds Max" height="80" width="79"/>
<strong>3DS MAX</strong>
</div>
<div>
<img src="img/c4d-logo.png" alt="Cinema 4D" height="80" width="79"/>
<strong>Cinema 4D</strong>
</div>
<div>
<img src="img/blender-logo.png" alt="Blender 3D" height="80" width="79"/>
<strong>Blender</strong>
</div>
</div>
</section>
<section>
<h4>How the process works</h4>
<p class="intro-text-process">Some text goes here </p>
</section>
<section>
<h4>Design Toolset</h4>
<p class="intro-text-toolset">Some text goes here.</p>
<div class="logos-all">
<div>
<img src="img/photoshop-logo.png" alt="Photoshop" height="80" width="79"/>
<strong>Photoshop</strong>
</div>
<div>
<img src="img/illustrator-logo.png" alt="Illustrator" height="80" width="79"/>
<strong>Illustrator</strong>
</div>
<div>
<img src="img/gimp-logo.png" alt="Gimp" height="80" width="79"/>
<strong>Gimp</strong>
</div>
<div>
<img src="img/inkscape-logo.png" alt="Inkscape"/>
<strong>Inkscape</strong>
</div>
</div>
</article>
</section>
Because your images are inline-block, you need to put text-align: center on the parent (the <div>).
Alternatively:
You could also make your images display: block
Or using flexbox:
Make your <div> display: flex; flex-direction: column and your image width: auto;
You can use floats to align blocks with images and text horizontally and text-align to align images and text inside them.
Overflow hidden inside section clears floats inside them, in case you'd want to have background on it and it wouldn't display properly.
.intro-text {
color: #000000;
display: block;
width: 100%;
margin: 50px 0 0 0;
text-align: justify;
line-height: 1.8em;
}
.intro-text-3d {
color: #000000;
display: block;
width: 100%;
text-align: center;
line-height: 1.8em;
}
.intro-text-process {
color: #000000;
display: block;
width: 100%;
text-align: center;
line-height: 1.8em;
}
.intro-text-toolset {
color: #000000;
display: block;
width: 100%;
text-align: center;
line-height: 1.8em;
}
/** Logos **/
.logos-all {
display: block;
text-align: center;
margin: 0 auto;
}
img {
display: inline-block;
margin: 0 auto;
vertical-align: middle;
border: 0;
line-height: 50px;
max-width: 100%;
width: 5%;
height: auto;
margin-bottom: .95em;
}
strong {
display: block;
font-weight: 700;
text-align: center;
}
section h4 {
text-align: center;
}
section {
overflow: hidden;
}
section > div {
text-align: center;
float: left;
width: 25%; /* 1/logos in row */
}
<article>
<section>
<p class="intro-text">
Some text goes here.
</p></div>
<div>
<img src="http://lorempixel.com/80/79" alt="CSS3" height="80" width="79"/>
<strong>CSS3</strong>
</div>
<div>
<img src="http://lorempixel.com/80/79" alt="Javascript" height="80" width="79"/>
<strong>Javascript</strong>
</div>
<div>
<img src="http://lorempixel.com/80/79" alt="Wordpress" height="80" width="79"/>
<strong>Wordpress</strong>
</div>
<div>
<img src="http://lorempixel.com/80/79" alt="PhP" height="80" width="79"/>
<strong>PhP</strong>
</div>
</div>
</section>
<section>
<p class="intro-text-3d">
Some text goes here
</p>
<div class="logos-all">
<div>
<img src="img/3ds max-logo.png" alt="3ds Max" height="80" width="79"/>
<strong>3DS MAX</strong>
</div>
<div>
<img src="img/c4d-logo.png" alt="Cinema 4D" height="80" width="79"/>
<strong>Cinema 4D</strong>
</div>
<div>
<img src="img/blender-logo.png" alt="Blender 3D" height="80" width="79"/>
<strong>Blender</strong>
</div>
</div>
</section>
<section>
<h4>How the process works</h4>
<p class="intro-text-process">Some text goes here </p>
</section>
If you wish to use Bootstrap you can use bootstrap panel .
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-body">
<img src="https://www.pushpraj.com/images/cool-scenery.jpg" class="img-rounded" alt="error" width="384" height="236">
</div>
<div class="panel-footer">Title 1</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-body">
<img src="https://www.pushpraj.com/images/cool-scenery.jpg" class="img-rounded" alt="error" width="384" height="236">
</div>
<div class="panel-footer">Title 2</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-body">
<img src="https://www.pushpraj.com/images/cool-scenery.jpg" class="img-rounded" alt="error" width="384" height="236">
</div>
<div class="panel-footer">Title 3</div>
</div>
</div>
</body>
</html>
I have some css issues. I'm trying to remove the space between a image and a label, and it does not work.
This is what I have:
And this is what I want:
I have problems with removing the space below he pictures and the same problem with the labels and the other div below them. In the same time I do not know how to position inline the headers from the footer.
This is my fiddle with my html and css:
https://jsfiddle.net/cwd6qw3o/
div img {
display: inline-block;
height: 30%;
width: 23%;
}
div.subtitle {
background-color: #333333;
color: white;
display: inline-block;
margin-top: 0;
text-align: left;
width: 23%;
}
div.subcolor {
background-color: #ba0927;
display: inline-block;
height: 5px;
width: 23%;
}
div.footer {
display: inline-block;
background-color: #e6e6e6;
width: 100%;
height: 5%;
}
Please tell me what i am doing wrong :).
Thanks !
I think it is not a good structure in your HTML,why not wrap your item in the same li such as
<ul>
<li>
<img src="~/Content/cont1.png"/>
<p>Bosch Car Service</p>
</li>
<li>
<img src="~/Content/cont2.png"/>
<p>Afspraak Proefrit</p>
</li>
<li>
<img src="~/Content/cont3.png"/>
<p>Afspraak onderhoud</p>
</li>
<li>
<img src="~/Content/cont4.png"/>
<p>Routebeschrijiving</p>
</li>
</ul>
You can remove spaces with the following CSS:
div {
font-size: 0;
}
div.subtitle {
font-size: 1rem;
}
Live preview: JSFiddle
Additional styling is necessary.
please try below code
div::after {
content: "";
width: 60%;
}
.image-div {
float: left;
width: 100%;
}
div img {
float: left;
height: 30%;
margin-right: 1%;
width: 23%;
}
div.subtitle {
background-color: #333333;
color: white;
float: left;
margin-right: 1%;
margin-top: 0;
text-align: left;
width: 23%;
}
.sub-div {
float: left;
width: 100%;
}
div.subcolor {
background-color: #ba0927;
float: left;
height: 5px;
margin-right: 1%;
width: 23%;
}
<body>
<img src="~/Content/slide1.png" id="slide" />
<div class="image-div">
<img src="http://dummyimage.com/200x200/000/fff"/>
<img src="http://dummyimage.com/200x200/000/fff" />
<img src="http://dummyimage.com/200x200/000/fff" />
<img src="http://dummyimage.com/200x200/000/fff" />
</div>
<div class="sub-div">
<div class="subtitle">
Bosch Car Service
</div>
<div class="subtitle">
Afspraak Proefrit
</div>
<div class="subtitle">
Afspraak onderhoud
</div>
<div class="subtitle">
Routebeschrijiving
</div>
</div>
<div>
<div class="subcolor" id="sub1"></div>
<div class="subcolor" id="sub2"></div>
<div class="subcolor" id="sub3"></div>
<div class="subcolor" id="sub4"></div>
</div>
<div class="footer">
<div class="images">
<img src="~/Content/fb.jpg"/>
<img src="~/Content/contact.jpg"/>
<img src="~/Content/route.jpg"/>
</div>
<div class="information">
<div class="contact">
<h1>Houman BVBA</h1>
<label>Boterstraat 6</label>
<label>B-2811 Hombeek (Mechelen)</label>
<label>Tel. 015 41 39 39</label>
<label>Fax. 015/43 24 40</label>
</div>
<div class="schedule">
<h1>Openingsuren</h1>
<label>Maandag: 9u-12u|13u-18u</label>
<label>Dinsdag: 9u-12u|13u-18u</label>
<label>Woensdag: 9u-12u|13u-18u</label>
<label>Donderdag: 9u-12u|13u-18u</label>
<label>Vrijdag: 9u-12u|13u-18u</label>
<label>Zaterdag: 9u-12u|13u-18u</label>
</div>
</div>
</div>
</body>
I'm trying to make these 4 images to be circle but I guess I'll just use images later but anyway. I'm trying to put a title under the image (bottom-middle) but instead its at the top. This is what happened.
.services img{
border-radius: 50%;
padding-left: 10px;
float: left;
display: block;
}
<section class="services">
<h1 style="text-align:center; font-size:38px;">Services we offer</h1>
<div class="circle">
<img src="http://placehold.it/290x250">
<h3>Title</h3>
</div>
<div class="circle">
<img src="http://placehold.it/290x250">
<h3>Title</h3>
</div>
<div class="circle">
<img src="http://placehold.it/290x250">
<h3>Title</h3>
</div>
<div class="circle">
<img src="http://placehold.it/290x250">
<h3>Title</h3>
</div>
</section>
So it'd look like my design.
You need also to set the .circle class to float left:
.circle
{
width: 25%;
float: left;
}
http://jsfiddle.net/yh988n5e/
.circle{
text-align: center;
display: inline-block;
}
.services img{
border-radius: 50%;
padding-left: 10px;
display: block;
}
http://jsfiddle.net/mx7xknzr/1/