2017-07-12 7 views
0

フッターの中央ボックスにテキストとアイコンを水平方向と垂直方向の中央に配置するのに問題があります。 HTMLとCSSシートは以下の通りです。私のコードを見て、私が必要とする変更と私の問題の解決方法を教えてください。CSSテキストとアイコンの中央揃えの問題

<style>.footer-distributed{ 
 
\t background-color: #292c2f; 
 
\t box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12); 
 
\t box-sizing: border-box; 
 
\t width: 100%; 
 
\t text-align: left; 
 
\t font: bold 16px sans-serif; 
 

 
\t padding: 55px 50px; 
 
\t margin-top: 80px; 
 
} 
 

 
.footer-distributed .footer-left, 
 
.footer-distributed .footer-center, 
 
.footer-distributed .footer-right{ 
 
\t display: inline-block; 
 
\t vertical-align: top; 
 
} 
 

 
/* Footer left */ 
 

 
.footer-distributed .footer-left{ 
 
\t width: 40%; 
 
} 
 

 
/* The company logo */ 
 

 
.footer-distributed h3{ 
 
\t color: #ffffff; 
 
\t font: normal 34px '', normal; 
 
\t margin: 20px ; 
 
} 
 

 
.footer-distributed h3 span{ 
 
\t color: #894FAB; 
 
} 
 

 
/* Footer links */ 
 

 
.footer-distributed .footer-links{ 
 
\t color: #ffffff; 
 
    font: normal 16px 'arial', normal; 
 
    text-transform: none; 
 
\t margin: 20px 0 12px; 
 
\t padding: 0; 
 
} 
 

 
.footer-distributed .footer-links a{ 
 
\t display:inline-block; 
 
\t font-size: 14; 
 
\t font-weight: normal; 
 
\t line-height: 1.8; 
 
\t text-decoration: none; 
 
\t color: inherit; 
 
} 
 

 
.footer-distributed .footer-company-name{ 
 
\t color: #8f9296; 
 
\t font-size: 14px; 
 
\t font-weight: normal; 
 
\t margin: 0; 
 
} 
 

 
.footer-distributed .footer-privacy-policy{ 
 
\t color: #8f9296; 
 
\t font-size: 14px; 
 
\t font-weight: normal; 
 
\t margin: 0; 
 
} 
 

 
/* Footer Center */ 
 

 
.footer-distributed .footer-center{ 
 
\t width: 35%; 
 
} 
 

 
.footer-distributed .footer-center i{ 
 
\t background-color: #33383b; 
 
\t color: #ffffff; 
 
\t font-size: 25px; 
 
\t width: 38px; 
 
\t height: 38px; 
 
\t border-radius: 50%; 
 
\t text-align: center; 
 
\t line-height: 42px; 
 
\t margin: 10px 15px; 
 
\t vertical-align: middle; 
 
} 
 

 
.footer-distributed .footer-center i.fa-envelope{ 
 
\t font-size: 17px; 
 
\t line-height: 38px; 
 
} 
 

 
.footer-distributed .footer-center p{ 
 
\t display: inline-block; 
 
\t color: #ffffff; 
 
\t vertical-align: middle; 
 
    text-align: center; 
 
\t margin:0; 
 
} 
 

 
.footer-distributed .footer-center p span{ 
 
\t display:block; 
 
\t font-weight: normal; 
 
\t font-size:14px; 
 
\t line-height:2; 
 
} 
 

 
.footer-distributed .footer-center p a{ 
 
\t color: #894FAB; 
 
\t text-decoration: none;; 
 
} 
 

 

 
/* Footer Right */ 
 

 
.footer-distributed .footer-right{ 
 
\t width: 20%; 
 
} 
 

 
.footer-distributed .footer-company-about{ 
 
\t line-height: 20px; 
 
\t color: #92999f; 
 
\t font-size: 13px; 
 
\t font-weight: normal; 
 
\t margin: 0; 
 
} 
 

 
.footer-distributed .footer-company-about span{ 
 
\t display: block; 
 
\t color: #ffffff; 
 
\t font-size: 14px; 
 
\t font-weight: bold; 
 
\t margin-bottom: 20px; 
 
} 
 

 
.footer-distributed .footer-icons{ 
 
\t margin-top: 25px; 
 
} 
 

 
.footer-distributed .footer-icons a{ 
 
\t display: inline-block; 
 
\t width: 35px; 
 
\t height: 35px; 
 
\t cursor: pointer; 
 
\t background-color: #33383b; 
 
\t border-radius: 2px; 
 

 
\t font-size: 20px; 
 
\t color: #ffffff; 
 
\t text-align: center; 
 
\t line-height: 35px; 
 

 
\t margin-right: 3px; 
 
\t margin-bottom: 5px; 
 
} 
 

 
/* If you don't want the footer to be responsive, remove these media queries */ 
 

 
@media (max-width: 880px) { 
 

 
\t .footer-distributed{ 
 
\t \t font: bold 14px ; 
 
\t } 
 

 
\t .footer-distributed .footer-left, 
 
\t .footer-distributed .footer-center, 
 
\t .footer-distributed .footer-right{ 
 
\t \t display: block; 
 
\t \t width: 100%; 
 
\t \t margin-bottom: 40px; 
 
\t \t text-align: center; 
 
\t } 
 

 
\t .footer-distributed .footer-center i{ 
 
\t \t margin-left: 0; 
 
\t } 
 
.footer-privacy-policy { 
 
} 
 

 
} 
 
</style>
<!DOCTYPE html> 
 
<html> 
 

 
    <script src="https://use.fontawesome.com/7b48e06cba.js"></script> 
 
    
 
\t <body> 
 

 
\t \t 
 
\t \t <!-- The content of your page would go here. --> 
 

 
\t \t <footer class="footer-distributed"> 
 

 
\t \t \t <div class="footer-left"> 
 

 
\t \t \t \t <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBQ9lFHOxqSd-Tx5713FBhTp4L5QsC1oxg"></script><div style='overflow:hidden;height:250px;width:auto; margin: 0 auto;'><div id='gmap_canvas' style='height:250px;width:auto; margin: 0 auto;'></div> 
 
       <style>#gmap_canvas img{max-width:none!important;background:none!important}</style></div><script type='text/javascript'>function init_map(){var myOptions = {zoom:12,center:new google.maps.LatLng(40.459225378643445,-86.84742606020508),mapTypeId: google.maps.MapTypeId.ROADMAP};map = new google.maps.Map(document.getElementById('gmap_canvas'), myOptions);marker = new google.maps.Marker({map: map,position: new google.maps.LatLng(40.459225378643445,-86.84742606020508)});infowindow = new 
 
google.maps.InfoWindow({content:'<strong>Bethany Childcare & Preschool</strong><br>3305 Longlois Dr., Lafayette, IN 47904<br>'});google.maps.event.addListener(marker, 'click', function()    {infowindow.open(map,marker);});infowindow.open(map,marker);}google.maps.event.addDomListener(window, 'load', init_map);</script> 
 

 
\t \t \t \t <p class="footer-links"> 
 
\t \t \t \t \t <a href="https://www.bccandp.org/">Home</a> 
 
\t \t \t \t \t · 
 
\t \t \t \t \t <a href="https://www.bccandp.org/contact">Contact</a> 
 
\t \t \t \t \t · 
 
\t \t \t \t \t <a href="https://www.bccandp.org/brightwheel">Brightwheel</a> 
 
\t \t \t \t \t · 
 
\t \t \t \t \t <a href="https://www.bccandp.org/programs">Programs</a> 
 
\t \t \t \t \t · 
 
\t \t \t \t \t <a href="https://www.bccandp.org/calendar">Calendar</a> 
 
\t \t \t \t  · 
 
\t \t \t \t \t <a href="https://www.bccandp.org/enrollment">Enrollment</a> 
 
\t \t \t \t \t · 
 
\t \t \t \t \t <a href="https://www.bccandp.org/staff">Staff</a> 
 
\t \t \t \t </p> 
 

 
\t \t \t \t <p class="footer-company-name">BCC&P DOT &copy; 2017 | 
 
\t \t \t \t \t <a href="https://www.bccandp.org/privacy" class="footer-privacy-policy">Privacy Policy</a></p> 
 
\t \t \t </div> 
 

 
\t \t \t <div class="footer-center"> 
 

 
\t \t \t \t <div> 
 
\t \t \t \t \t <i class="fa fa-map-marker"></i> 
 
\t \t \t \t \t <p><span>3305 Longlois Dr.</span> Lafayette, Indiana</p> 
 
\t \t \t \t </div> 
 

 
\t \t \t \t <div> 
 
\t \t \t \t \t <i class="fa fa-phone"></i> 
 
\t \t \t \t \t <p>+1.765.447.7044 X.2</p> 
 
\t \t \t \t </div> 
 

 
\t \t \t \t <div> 
 
\t \t \t \t \t <i class="fa fa-envelope"></i> 
 
\t \t \t \t \t <p><a href="mailto:[email protected]">[email protected]</a></p> 
 
\t \t \t \t </div> 
 

 
\t \t \t </div> 
 

 
\t \t \t <div class="footer-right"> 
 

 
\t \t \t \t <p class="footer-company-about"> 
 
\t \t \t \t \t <span>About Us</span> 
 
\t \t \t \t \t We are an Indiana State registered childcare and preschool ministry of Bethany Presbyterian Church. Our primary focus is on the community of Lafayette, Indiana and its surrounding communities. We are a Child Care Development Fund (CCDF) provider. Founded in 1988. 
 
\t \t \t \t </p> 
 

 
\t \t \t \t <div class="footer-icons"> 
 

 
\t \t \t \t \t <a href="https://www.facebook.com/bccandp"><i class="fa fa-facebook"></i></a> 
 
\t \t \t \t \t <a href="#"><i class="fa fa-twitter"></i></a> 
 
\t \t \t \t \t <a href="#"><i class="fa fa-linkedin"></i></a> 
 
\t \t \t \t \t <a href="#"><i class="fa fa-github"></i></a> 
 

 
\t \t \t \t </div> 
 

 
\t \t \t </div> 
 

 
\t \t </footer> 
 

 
\t </body> 
 
    
 
</html>

答えて

0

コンテンツを包むDIVを作成します。これはページに配置する責任があるdivになります。今

<div class="footer-center"> 

    <div class="wrapper"> 
     <div> 
      <i class="fa fa-map-marker"></i> 
      <p><span>3305 Longlois Dr.</span> Lafayette, Indiana</p> 
     </div> 

     <div> 
      <i class="fa fa-phone"></i> 
      <p>+1.765.447.7044 X.2</p> 
     </div> 

     <div> 
      <i class="fa fa-envelope"></i> 
      <p><a href="mailto:[email protected]">[email protected]</a></p> 
     </div> 

    </div> 
</div> 

、ちょうどそれがテキスト中心を有する、ラッパーが中央に配置されます父のことを考えると、ラッパーインラインブロックを作ります。 テキストと、ラッパー内のその他すべてのものを左揃えにします。

0

私はこのエラーが原因にあなたのサンプルを実行することができません:

"Google Maps API error: RefererNotAllowedMapError https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error 
Your site URL to be authorized: https://stacksnippets.net/js" 

だから私はあなたが直面しているものと暗闇の中で少しです。しかし、私は垂直アライメントが必要なとき私はフレックスボックスに行く。

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

(そして時にはマージンやって::;が同様に必要である0オート)を含む要素に すなわち。

アイコンとラベルが縦に並んでいない場合は、常に負のピクセル値で縦線を使用しています。つまり、

vertical-align: -2px; 
+0

私のAPIキーでエラーを修正しました。私のコードを調べてくれてありがとうございます。 –

+0

コードサンプルをスリムにして、動作していない部分だけに焦点を当てることをお勧めします。問題に関連していないものがたくさんあります。 – flyer

関連する問題