I want to create a website as a portfolio for my other work. However I'm having a lot of trouble with centering text within my links. I've tried multiple methods to no avail.
The text I'm trying to alter is the text in the navigation section "about me" "portfolio" "skills" "contact" The text is within a row-->column-->link
I've attempted applying the text-center class in multiple different positions throughout the code and I've also tried applying it within my CSS using the text-align function. There isn't too much code so I imagine that someone with a bit of HTML experience will solve this in no time.
#mainContainer{
z-index:0;position:fixed;
width:100%; height:100%;
background-color: white;
}
.headerClass{
margin-top:auto;
margin-bottom:auto;
}
#headText{
color:white;
font-size: 1.5vw;
font-family: fantasy;
vertical-align: middle;
}
#infoBox{
height:100%;
width:100%;
}
#infoBoxCol{
background-repeat: no-repeat;
background-size:cover;
}
.navbar{
border-style: solid;
border-color: white;
width: 100%;
color:white;
font-family:fantasy;
font-size: 1.1vw;
text-align:center;
}
.navRoof{
text-align:center;
width:100%;
height:10%;
background-color:white;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="container-fluid text-center" id="mainContainer">
<div class="row" style="background-color: black; height:30%;">
<div class="col-4 my-auto text-fluid" class="headerClass" id="headText">
Software Developer
</div>
<div class="col-1"></div>
<div class="col-2 my-auto"><img class="img-fluid" src="images/logo.jpg" style="max-width:85%;"></div>
<div class="col-1"></div>
<div class="col-4 my-auto">
<div class="row" id="navigation">
<div class="col-3">About Me</div>
<div class="col-3">Portfolio</div>
<div class="col-3">Skills</div>
<div class="col-3">Contact</div>
</div>
</div>
</div>
</div>
Here i using bootstrap flex instead of row > col-* to have a more flexible design, one thing that you are doing wrong is u are overwriting the bootstrap class "navbar" it have his properties more your news properties this make your design problems. Also is bad idea use vw as unit for font-size if u want get responsive design.
#mainContainer{
z-index:0;position:fixed;
width:100%; height:100%;
background-color: white;
}
.headerClass{
margin-top:auto;
margin-bottom:auto;
}
#headText{
color:white;
font-size: 1.5vw;
font-family: fantasy;
vertical-align: middle;
}
#infoBox{
height:100%;
width:100%;
}
#infoBoxCol{
background-repeat: no-repeat;
background-size:cover;
}
.navRoof{
text-align:center;
width:100%;
height:10%;
background-color:white;
}
.custom-navbar-container {
border-style: solid;
border-color: white;
}
.custom-link {
white-space: nowrap;
color:white;
font-family:fantasy;
font-size: 1.1vw;
padding: .25rem;
display: block;
}
.custom-link:hover {
text-decoration: none;
color: grey;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="container-fluid text-center" id="mainContainer">
<div class="row" style="background-color: black; height:30%;">
<div class="col-4 my-auto text-fluid" class="headerClass" id="headText">
Software Developer
</div>
<div class="col-1"></div>
<div class="col-2 my-auto"><img class="img-fluid" src="images/logo.jpg" style="max-width:85%;"></div>
<div class="col-1"></div>
<div class="col-4 my-auto">
<div class="d-flex" id="navigation">
<div class="p-1">
<div class="custom-navbar-container">
About Me
</div>
</div>
<div class="p-1">
<div class="custom-navbar-container">
Portfolio
</div>
</div>
<div class="p-1">
<div class="custom-navbar-container">
Skills
</div>
</div>
<div class="p-1">
<div class="custom-navbar-container">
Contact
</div>
</div>
</div>
</div>
</div>
</div>
Related
I am making a webpage in which I want to make 2 image thumbnails appear adjacent to each other with same height.
Consider my html code:
<div class="row">
<div class="col-md-6">
<img src="http://i.imgur.com/Ym35iJI.jpg" alt="frontend" class="img-thumbnail" width="640px" height="480px">
</div>
<div class="col-md-6">
<img src="http://i.imgur.com/ot6RubY.jpg" alt="webd" class="img-thumbnail" width="640px" height="480px">
</div>
</div>
Corresponding to the given code in the output it shows(this is just a cropimage of the output) :
I cant see why the height attribute doesnt assign same height to both the images
As asked in one of the answers here is the css file:
body{
background-color: rgb(45,45,45);
}
.page-header{
height: 100px;
background-color: rgb(17, 17, 17);
margin-top: 0px;
margin-bottom: 0px;
}
#title{
font-size:400%;
color: white;
font-family: 'Oswald', sans-serif;
}
.nav-button{
margin-top:24px;
margin-right:50px;
margin-left:50px;
width:110px;
height:55px;
}
.btn h3{
margin: 0 auto;
font-family: 'Cabin', sans-serif;
}
.about{
background-color: rgb(175, 187, 206);
height:300px;
font-size:16px;
}
.container{
margin-top:0px;
}
.body-text{
font-family:'Cabin', sans-serif;
padding-top:60px;
padding-left:25px;
font-size:175%;
}
.my-image{
height:280px;
width:270px;
padding-top:20px;
padding-right:30px;
}
.portfolio{
height: 1200px;
}
#portfolio-heading{
padding-top: 30px;
color: rgb(255,255,255);
}
This can be done using CSS:-
https://jsfiddle.net/Lrbw117q/1/
You can also put the background image inline if you need to.
#box1 {
background-image: url('http://i.imgur.com/Ym35iJI.jpg');
background-size: cover;
}
#box2 {
background-image: url('http://i.imgur.com/ot6RubY.jpg');
background-size: cover;
}
.img-thumbnail {
height: 640px;
width: 480px;
border: 5px solid red;
}
I just placed your code into a fresh html file, and tested it. Both images are given the exact same height. I personally would check your stylesheet for any inconsistencies in any of the mentioned classes/IDs, or anything that could have affected its size.
You may want to check for your styling for a
'height:auto;'
or the like.
My suggestion would be to put a 'overflow:hidden;' into your stylesheet "img-thumbnail" class.
To be able to successfully fix this for you, we would need to see more of your code.
Edit: Also, I may suggest that you check to see which of the divs is the incorrect height. In chrome, this can be done by inspecting element (right-click > inspect element), navigating to the code in question, and hovering over it. This should hopefully determine your issue.
You can do this with flex property try the demo
.outer , .outer div {
display:flex;
}
<div class="row">
<div class="outer">
<div class="col-md-6 col-sm-6 col-xs-6">
<img src="http://i.imgur.com/Ym35iJI.jpg" alt="frontend" class="img-thumbnail" width="640px" height="480px">
</div>
<div class="col-md-6 col-sm-6 col-xs-6">
<img src="http://i.imgur.com/ot6RubY.jpg" alt="webd" class="img-thumbnail" width="640px" height="480px">
</div>
</div>
</div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
The width and height attribute doesn't work on an image:
You should do this:
<div class="row">
<div class="col-md-6">
<img src="http://i.imgur.com/Ym35iJI.jpg" alt="frontend" class="img-thumbnail" style="widht: 640px; height:480px;" />
</div>
<div class="col-md-6">
<img src="http://i.imgur.com/ot6RubY.jpg" alt="webd" class="img-thumbnail" style="widht: 640px; height:480px;">
</div>
</div>
Better practice however is that make you own class:
<div class="row">
<div class="col-md-6">
<img class="myClass" src="http://i.imgur.com/Ym35iJI.jpg" alt="frontend" class="img-thumbnail" />
</div>
<div class="col-md-6">
<img class="myClass" src="http://i.imgur.com/ot6RubY.jpg" alt="webd" class="img-thumbnail" style="widht: 640px; height:480px;">
</div>
</div>
And make a css-file with following code:
.myClass {
width: 640px;
height: 480px;
}
I however suggest the following thing. Make sure your images have the same size in advance using an editing tool (i.e. Photoshop) and use the default img-responsive class that comes standard with bootstrap.
This will make your website more responsive which is preferred.
you can use this code:
div.col-md-6 {
height:400px;
position:relative;
display:inline-block;
overflow:hidden;
}
img.img-thumbnail {
position:absolute;
top:50%;
min-height:100%;
display:block;
left:50%;
-webkit-transform: translate(-50%, -50%);
min-width:100%;
}
<div class="row">
<div class="col-md-6">
<img src="http://i.imgur.com/Ym35iJI.jpg" alt="frontend" class="img-thumbnail" style="height: 500px;background-size: cover;"/>
</div>
<div class="col-md-6">
<img src="http://i.imgur.com/ot6RubY.jpg" alt="webd" class="img-thumbnail" style="height: 500px;background-size: cover;"/>
</div>
I need to make responsive layout, but my menu crashing like in the picture. I need to make menu in the right position, so in my css I added right:0px. How I should make menu with right position and working responsive.
This is how it looks with right position.
But when I delete right:0px; everything is working, BUT I need right position.
Example without right position
<div class="row" id="menu_section">
<div style=" margin-top:20px" class="four columns">
<img class="img" src="images/logo.png">
</div>
<div class="eight columns">
<div id="menuSection">
<div class="menu top">
<div class="item">Registrati</div>
<div class="item">Accedi</div>
<div class="item"><img src="images/shoppingCart.png"></div>
</div>
<div class="menu bottom">
<div class="item"><b>C</b>osa fare</div>
<div class="item"><b>O</b>rdina ora</div>
<div class="item"><b>A</b>ziende</div>
<div class="item"><b>F</b>ilosofia</div>
<div class="item"><b>C</b>ontatti</div>
</div>
</div>
</div>
</div>
#menuSection{
right: 0px;
bottom:0px;
position: absolute;
margin-bottom: 5px;
}
#menu_section{
padding-top: 10px;
padding-bottom: 10px;
}
.menu.top{
margin-left:auto;
text-align: right;
padding-bottom:20px;
}
.menu.bottom{
margin-top:auto;
text-align: right;
}
.img{
max-width:100%;
position: relative;
bottom: 0;
display:table;
display:block;
margin:auto;"
}
I am trying to get text to vertically align to the middle but can't seem to get it to work.
HTML:
<div class="row">
<div class="col-md-4">
Login
</div>
<div class="col-md-4">
Menu
</div>
<div class="col-md-4">
Contact
</div>
</div>
CSS:
.custom-button {
color:#ECDBFF;
background-color:#4F0100;
display:inline-block;
height: 220px;
font-family:Verdana, Geneva, sans-serif;
font-size:20px;
font-weight:bold;
text-align:center;
text-decoration:none;
}
.width-100 {width: 100%;}
I have googled quite a bit and tried a couple of things but i can't seem to get the text to go to the middle. can anyone advise what i would need to add/change to get this to work.
If your have a text which is restricted to single line then line-height would be the best solution.
try with this
line-height:220px; /*height of your container */
JsFiddle Demo
You can as well use vertical-align a pseudo element (:before or :after ) and an extra box (inline-block) to allow content to wrap on a few lines : see and run snippet below.
.custom-button {
color: #ECDBFF;
background-color: #4F0100;
display: inline-block;
height: 220px;
font-family: Verdana, Geneva, sans-serif;
font-size: 20px;
font-weight: bold;
text-align: center;
text-decoration: none;
}
.width-100 {
width: 100%;
}
.custom-button:before {
display:inline-block;
content:'';
height:220px;
vertical-align:middle;
margin:-0 -0.25em;;
}
a span {display:inline-block;
vertical-align:middle;
}
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"/>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css"/>
<div class="row">
<div class="col-md-4 col-xs-4">
Login
</div>
<div class="col-md-4 col-xs-4">
Menu
</div>
<div class="col-md-4 col-xs-4">
<span>Cont<br/>act</span>
</div>
</div>
The best way to describe what I want to do is using this image. As you can see I have 3 different images as background (which are three different Divs) and I want to insert 3 List Points (here named as: "LV", "RP", "IP") with a centred description/heading below (here as: Lv: 15, RP: 16975 and so on).
My biggest problem is to handle the centred width of those elements. I have no idea how to solve this the best way regarding the CSS.
My HTML:
<div class="package">
<div class="item-description">
<div class="col-md-3"><span class="title">LV</span><span class="description">15</span></div>
<div class="col-md-3"><span class="title">RP<span><span class="description">16975</span></div>
<div class="col-md-3"><span class="title">IP<span><span class="description">40000</span></div>
</div>
</div>
Are you looking for something like this?
It's using quite a few elements (which could possibly be converted into pseudo elements), but it shows a general overview of what you might be looking for.
Also, with the id's and classes this shouldn't make it too hard to alter for your needs.
.container {
width: 32%;
height: 200px;
background: red;
display: inline-block;
}
.container .title {
margin-top: 100px;
width: 32%;
height: 100%;
display: inline-block;
vertical-align: middle;
text-align: center;
color: white;
}
#one {
background: url(http://placekitten.com/g/300/300);
}
#two {
background: url(http://placekitten.com/g/200/200);
}
#three {
background: url(http://placekitten.com/g/300/200);
}
<div id="one" class="container">
<div class="title">200
<div class="desc">I'm a very long description</div>
</div>
<div class="title">300
<div class="desc">desc</div>
</div>
<div class="title">400
<div class="desc">Be More Dog</div>
</div>
</div>
<div id="two" class="container">
<div class="title">200
<div class="desc">desc</div>
</div>
<div class="title">300
<div class="desc">I'm a tree.</div>
</div>
<div class="title">400
<div class="desc">What is a description?</div>
</div>
</div>
<div id="three" class="container">
<div class="title">200
<div class="desc">desc</div>
</div>
<div class="title">300
<div class="desc">a description of what?</div>
</div>
<div class="title">400
<div class="desc">Don't you like, er, trees?</div>
</div>
</div>
this might also work:
Note: I've used a pseudo effect here, but to keep my code 'minimal', rather than applying it to individual items (as you would for individual descriptions), i've just used an existing item.
html,
body {
margin: 0;
padding: 0;
}
.sec {
width: 33%;
height: 200px;
background: red;
background: url(http://placekitten.com/g/200/200);
position: relative;
text-align: center;
color: white;
vertical-align: middle;
display: inline-block;
line-height: 200px;
margin-left: -0.5%;
}
.col {
width: 32%;
margin-left: -0.5%;
font-size: 25px;
display: inline-block;
position:relative;
}
.col:after{
padding-top:25px;
font-size: 10px;
position:absolute;
content:"description";
left:25%;
}
<div class="sec">
<div class="col">
title
</div>
<div class="col">
title2
</div>
<div class="col">
title3
</div>
</div>
<div class="sec">
<div class="col">
title
</div>
<div class="col">
title2
</div>
<div class="col">
title3
</div>
</div>
<div class="sec">
<div class="col">
title
</div>
<div class="col">
title2
</div>
<div class="col">
title3
</div>
</div>
Try this in your css
.description, .title{float:left; width:100%; text-align:center;}
So my logic of Div ID's and Classes must be WAY off.
Heres whats going on:
As you can see the blocks which say PS don't align center with the slider (Which is inside a container.
Here is my css:
/*Front Page Buttons */
#frontpage-Button-Cont {
height: 350px;
}
.button-cont {
width: 175px;
float: left;
margin-left: 10px;
margin-top: 10px;
height: 250px;
}
.thumbnail {
color: #fff;
font-size: 5em;
background: #1f4e9b;
width: 175px;
height: 135px;
text-align: center;
}
.pheader {
color: #DC143C;
min-width: 175px;
text-align: center;
}
.paragraph {
text-align: center;
}
#Align-content {
margin: 0 auto;
}
And here is the html:
<div id="frontpage-Button-Cont">
<div id="Align-content">
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
</div>
</div>
My theory is that I'm using classes incorrectly?
Thanks.
You can Add this to your CSS
#frontpage-Button-Cont {
width:100%;
}
#Align-content {
display:table;
}
With this your margin:o auto can work
View This Demo http://jsfiddle.net/VGPeW/
You need to make sure that the containing div (in this case frontpage-Button-Cont) is the same width as your slider above it. Then add the property text-align:center to the container. That should fix your issue.