Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Urgent Help with HTML CSS Positioning

Posted on 2016-11-18
9
Medium Priority
?
91 Views
Last Modified: 2016-11-18
Hi all,

I am trying to get

The text and download buttons to be in the centre of this div, height and width.

My code just don't seem to work I have tried everything. any help is highly appreciated, Thanks.

Here is the design

Screen-Shot-2016-11-18-at-13.52.05.png
Here is My code

HTML

<div id="clear"></div>
       
          <div id="downloadsection">
          <div id="downloadtext">
          <h1>Download the app Today!</h1>
          <div class="button3">TRY APP</div>
          <div class="button4">BUY APP</div>
          </div>
          </div>

Open in new window


CSS

/* START DOWNLOAD SECTION */

#downloadsection {
    background-color: #0C2633;
    height: 400px; 
    width: 100%;
}

#downloadsection h1{
    margin: top: 50px;  
    text-align: center;
    margin-bottom: 20px;
    color: #1da6c4; 
    font-size: 35px; 
    text-transform: uppercase;
    
}

#downloadtext {
      
    width: 52%;
    background-color: pink;
    display: block; 
    margin: 0 auto; 
    

}

Open in new window


I really need to get this sorted asap.

Thanks Again.
0
Comment
Question by:Mike Moore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 10

Expert Comment

by:Paweł
ID: 41892852
here you go

http://codepen.io/chooch/pen/vygBJP

<div id="clear"></div>

<div id="downloadsection">
  <div id="downloadtext">
    <h1>Download the app Today!</h1>
    <span class="button">TRY APP</span>
    <span class="button">BUY APP</span>
  </div>
</div>


/* START DOWNLOAD SECTION */

#downloadsection {
    background-color: #0C2633;
    height: 400px;
    width: 100%;
    display: flex;
  flex-direction: column;
  justify-content: center;
}

#downloadsection h1{
    margin: top: 50px;  
    text-align: center;
    margin-bottom: 20px;
    color: #1da6c4;
    font-size: 35px;
    text-transform: uppercase;
   
}

#downloadtext {
  margin:50% auto;
     text-align: center;
    width: 52%;
    background-color: pink;
    display: block;
    margin: 0 auto;
}
   


just made you two link buttons into inline elements that means they'll just render next to each other as long as they have space, then i just centered everything in your containing div. an volia
0
 

Author Comment

by:Mike Moore
ID: 41892857
Hi, what did you change? sorry I'm new to web dev.

Thanks
0
 
LVL 10

Accepted Solution

by:
Paweł earned 2000 total points
ID: 41892863
no worries, takes a bit to get a handle on it. i made the outer container the box that contains the pink content one into a flex box and set it's properties


  display: flex;
  flex-direction: column;
  justify-content: center;

actually rather than me give you a second hand explanation, check out the following
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Closing Comment

by:Mike Moore
ID: 41892875
Thanks a bunch.

I am in my 1st month at uni so this really helps.

Regards,
Mike
0
 

Author Comment

by:Mike Moore
ID: 41892884
just one more thing, sorry.

I can't get the text to align inside the buttons also same sort of problem.

any idea?

Screen-Shot-2016-11-18-at-14.22.33.png
Thanks
0
 
LVL 10

Expert Comment

by:Paweł
ID: 41892893
so the buttons are inside span tags now, which are inline elements, what i would do is give them a padding something like

.button{
  background-color:red;
  padding: 2px 10px;
}

that or give them a static width and change the display of the element to inline-block

.button{
  background-color:red;
  width:200px;
  display:inline-block;
  text-align:center;
}

the text-align:center is probably not needed,

take a look at the codepen
0
 
LVL 10

Expert Comment

by:Paweł
ID: 41892901
0
 
LVL 59

Expert Comment

by:Julian Hansen
ID: 41892917
Flex has cross browser limitations. Another option is to use display: table like so
<style type="text/css">
#downloadsection {
  background-color: #0C2633;
  height: 400px; 
  width: 100%;
  display: table;
}
#downloadsection h1 {
  margin: top: 50px;  
  text-align: center;
  margin-bottom: 20px;
  color: #1da6c4; 
  font-size: 35px; 
  text-transform: uppercase;
}
#downloadtext {
  width: 100%;
  text-align: center;
  display: table-cell;
  height: 100%;
  vertical-align: middle;
}
.button {
  border-radius: 5px;
  padding: 5px 25px;
  color: white;
  font-size: 25px;
  margin-left: 15px;
}
.button3 {
  background: #1fb18a;
}
.button4 {
  background: #1ea6c4;
}
</style>

Open in new window

HTML
    <div id="clear"></div>
      <div id="downloadsection">
        <div id="downloadtext">
          <h1>Download the app Today!</h1>
          <a class="button button3">TRY APP</a>
          <a class="button button4">BUY APP</a>
      </div>
    </div>

Open in new window


Working sample here
0
 

Author Comment

by:Mike Moore
ID: 41892923
Thanks I appreciate all your help. I will give it a shot.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question